0% found this document useful (0 votes)
58 views

Section 2 Basic Linux Command

The document provides information about basic Linux commands for network administration. It defines two types of commands - built-in shell commands that are part of the shell and external commands that are separate executable programs. It then describes commands for navigating directories, listing files, creating/viewing/deleting files and directories, getting help, and clearing the terminal screen. The document also includes examples of using commands like ls, cd, pwd, cat, rm, mv, mkdir, rmdir, man, history and clear.

Uploaded by

phochny chhin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Section 2 Basic Linux Command

The document provides information about basic Linux commands for network administration. It defines two types of commands - built-in shell commands that are part of the shell and external commands that are separate executable programs. It then describes commands for navigating directories, listing files, creating/viewing/deleting files and directories, getting help, and clearing the terminal screen. The document also includes examples of using commands like ls, cd, pwd, cat, rm, mv, mkdir, rmdir, man, history and clear.

Uploaded by

phochny chhin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Linux Network Administration

By Bean Bee
6/24/2021 1
 In Linux, commands are ways or instructions
through which you can instruct your system to do
some action. Commands are executed in the
command line.
 This command further passes to the shell which
reads the command and execute it. Shell is a method
for the user to interact with the system. Default shell
in Linux is called bash (Bourne-Again Shell).

6/24/2021 2
 There are two types of shell commands:

• Built-in shell commands: They are part of a shell.


Each shell has some built in commands.
• Some example of built-in commands are 'pwd', 'help', 'type',
'set', 'unset', etc.

• External/Linux commands: Each external command


is a separate executable program written in C or
other programming languages.
• Mostly these commands reside in /bin, /sbin, /usr/sbin.

6/24/2021 3
Directory
Description
Command

The pwd command stands for (print working directory). It


displays the current working location or directory of the
pwd user. It displays the whole working path starting with /. It
is a built-in command.

The ls command is used to show the list of a folder. It will


ls list out all the files in the directed folder.

The cd command stands for (change directory). It is used


cd to change to the directory you want to work from the
present directory.

mkdir With mkdir command you can create your own directory.

The rmdir command is used to remove a directory from


rmdir your system.
6/24/2021 4
 There are 2 ways to launch the terminal.
 1) Go to the Dash and type terminal
 2) Or you can press CTRL + Alt + T to launch
the Terminal

6/24/2021 5
 Once you launch the CLI (Terminal), you would
find something as guru99@VirtualBox(see
image) written on it.

6/24/2021 6
 pwd command stands for print working
directory

 Above figure shows that /home/guru99 is the


directory we are currently working on.

6/24/2021 7
 If you want to change your current directory
use the 'cd' command.
 cd /tem

 Here, we moved from directory /tmp to /bin


to /usr and then back to /tmp.

6/24/2021 8
 If you want to navigate to the home directory,
then type cd.

 You can also use the cd ~ command.

6/24/2021 9
 The root of the file system in Linux is
denoted by '/'. Similar to 'c:\' in Windows.
 Note: In Windows, you use backward slash "\"
while in UNIX/Linux, forward slash is used "/“
 Type 'cd /' to move to the root directory.

6/24/2021 10
 You can navigate through multiple directories
at the same time by specifying its complete
path.

Moving up one directory level


For navigating up one directory level, try.
cd ..

6/24/2021 11
 A path in computing is the address of a file or folder.

 Example
◦ In Windows
◦ C:\documentsandsettings\user\downloads

◦ In Linux
◦ /home/user/downloads

There are two kinds of paths:

6/24/2021 12
 An absolute path refers to the complete details needed
to locate a file or folder, starting from the root
element and ending with the other subdirectories.

 To navigate to this directory, you can use the


command.
 cd /home/guru99/Pictures

 This is called absolute path as you are specifying the


full path to reach the file.

6/24/2021 13
 A relative path refers to a location that is relative to a
current directory
 You do no need to type the absolute path

 cd /home/guru99/Downloads

 Instead, you can simply type 'cd Downloads'

6/24/2021 14
Listing files (ls) command
 If you want to see the list of files on your UNIX or Linux
system, use the 'ls' command.
 It shows the files /directories in your current directory.

Note:

▪ Directories are denoted in blue color.


▪ Files are denoted in white.
▪ You will find similar color schemes in different flavors of Linux.

6/24/2021 15
Listing files (ls) command
Suppose, your "Music" folder has following sub-directories and
files.

6/24/2021 16
Listing files (ls) command
You can use 'ls -R' to shows all the files not only in directories but also
subdirectories.

6/24/2021 17
Listing files (ls) command
The 'ls -al' gives detailed information of the files

6/24/2021 18
Listing Hidden Files
 Hidden items in UNIX/Linux begin with ‘.’ (period symbol) at
the start, of the file or directory.

Ls –a

6/24/2021 19
Creating & Viewing Files
 The 'cat' command is used to display text files,
copying, combining and creating new text files.
 To create a new file, use the command
1. cat > filename
2. Add content
3. Press 'ctrl + d' to return to command prompt.

6/24/2021 20
Creating & Viewing Files
 To view a file, use the command –

cat filename

6/24/2021 21
Deleting Files
 The 'rm' command removes files from the system without
confirmation.
To remove a file use syntax –
rm filename

6/24/2021 22
Moving and Re-naming files
To move a file, use the command.
mv filename new_file_location

sudo command_you_want_to_execute
For renaming file:

mv filename newfilename

6/24/2021 23
Creating Directories
Directories can be created on a Linux operating system using the following
command.

mkdir directoryname

For example,

mkdir mydirectory

6/24/2021 24
 Removing Directories
 To remove a directory, use the command –
rmdir directoryname

To Remove files/sub-directory use the command


rm –r directoryname

6/24/2021 25
 The 'Man' command
Man stands for manual which is a reference book of a Linux operating system.
It is similar to HELP.
 To get help on any command that you do not understand, you can type
man

6/24/2021 26
 The History Command
History command shows all the basic commands in Linux that you have
used in the past for the current terminal session.

6/24/2021 27
 The clear command
This command clears all the clutter on the terminal and gives you
a clean window to work on, just like when you launch the
terminal.

6/24/2021 28
Command Description

Lists all files and directories in the present


ls
working directory

ls - R Lists files in sub-directories as well

ls - a Lists hidden files as well

Lists files and directories with detailed


ls - al information like permissions, size, owner,
etc.

cat > filename Creates a new file

cat filename Displays the file content

Joins two files (file1, file2) and stores the


cat file1 file2 > file3
output in a new file (file3)

6/24/2021 29
mv file "new file path" Moves the files to the new location
mv filename new_file_name Renames the file to a new filename
Allows regular users to run programs with
sudo the security privileges of the superuser or
root
rm filename Deletes a file

man Gives help information on a command

Gives a list of all past basic Linux commands


history
list typed in the current terminal session

clear Clears the terminal

Creates a new directory in the present


mkdir directoryname
working directory or a at the specified path

6/24/2021 30
rmdir Deletes a directory
mv Renames a directory
pr -x Divides the file into x columns
pr -h Assigns a header to the file
pr -n Denotes the file with Line Numbers
lp -nc
Prints "c" copies of the File
lpr c
lp -d lpr -P Specifies name of the printer
Command used to install and update
apt-get
packages
mail -s 'subject' -c 'cc-address' -b
Command to send email
'bcc-address' 'to-address'
mail -s "Subject" to-address < Command to send email with
Filename attachment

More: https://www.javatpoint.com/linux-commands-list

6/24/2021 31
 Filesystem hierarchy standard describes
directory structure and its content in Unix and
Unix like operating system. It explains where
files and directories should be located and
what it should contain.

6/24/2021 32
6/24/2021 33
 Main directories
/bin is a place for most commonly used terminal commands,
like ls, mount, rm, etc.
/boot contains files needed to start up the system, including
the Linux kernel, a RAM disk image and bootloader
configuration files.
/dev contains all device files, which are not regular files but
instead refer to various hardware devices on the system,
including hard drives.

6/24/2021 34
 /etc contains system-global configuration
files, which affect the system's behavior for
all users.
 /home home sweet home, this is the place
for users' home directories.
 /lib contains very important dynamic
libraries and kernel modules

6/24/2021 35
 /media is intended as a mount point for
external devices, such as hard drives or
removable media (floppies, CDs, DVDs).
 /mnt is also a place for mount points, but
dedicated specifically to "temporarily
mounted" devices, such as network
filesystems.

6/24/2021 36
/opt can be used to store additional software for
your system, which is not handled by the package
manager.
/proc is a virtual filesystem that provides a
mechanism for kernel to send information to
processes.
/root is the superuser's home directory, not in
/home/ to allow for booting the system even if
/home/ is not available.

6/24/2021 37
/run is a tmpfs (temporary file system) available
early in the boot process where ephemeral run-
time data is stored. Files under this directory are
removed or truncated at the beginning of the boot
process.
(It deprecates various legacy locations such as
/var/run, /var/lock, /lib/init/rw in otherwise non-
ephemeral directory trees as well as /dev/.* and
/dev/shm which are not device files.)

6/24/2021 38
/sbin contains important administrative
commands that should generally only be
employed by the superuser.
/srv can contain data directories of services such
as HTTP (/srv/www/) or FTP.
/sys is a virtual filesystem that can be accessed
to set or obtain information about the kernel's
view of the system.

6/24/2021 39
/tmp is a place for temporary files used by
applications.
/usr contains the majority of user utilities and
applications, and partly replicates the root directory
structure, containing for instance, among others,
/usr/bin/ and /usr/lib.
/var is dedicated to variable data, such as logs,
databases, websites, and temporary spool (e-mail
etc.) files that persist from one boot to the next. A
notable directory it contains is /var/log where
system log files are kept.
6/24/2021 40
 To manage your files, you can use either the
GUI(File manager) or the CLI(Terminal) in Linux.
Both have its relative advantages. In the tutorial
series, we will focus on the CLI.
 You can launch the terminal from the dashboard or
use the shortcut key Cntrl + Alt + T
 The pwd command gives the present working
directory.
 You can use the cd command to change directories
 Absolute path is complete address of a file or
directory
 Relative path is relative location of a file of
directory with respect to current directory
6/24/2021 41
 Linux Filesystem Tree Overview
◦ https://help.ubuntu.com/community/LinuxFilesyst
emTreeOverview
 Linux Command Line Tutorial
◦ https://www.guru99.com/terminal-file-
manager.html

6/24/2021 42
6/24/2021 43

You might also like