OsLab Linux Commands
OsLab Linux Commands
Date:17-05-2022
1 Commands
1.1 touch
1.1.1 Description
Used to make a new file in current directory.
1.1.2 Syntax
touch filename
1.2 mkdir
1.2.1 Description
Used to make a new directory in current directory.
1.2.2 Syntax
mkdir directory_name
1.3 pwd 1 COMMANDS
1.3 pwd
1.3.1 Description
Prints the present working directory
1.3.2 Syntax
pwd
1.4 cd
1.4.1 Description
Used to change directory
1.4.2 Syntax
cd directory_name
2
1.5 cat 1 COMMANDS
1.5 cat
1.5.1 Description
Views the content of a file
1.5.2 Syntax
cat filename
1.6 more
1.6.1 Description
Views the content of a file one scornful at a time
1.6.2 Syntax
more filename
1.7 ls
1.7.1 Description
List files in a directory.
1.7.2 Syntax
ls
3
1.8 ls -l 1 COMMANDS
1.8 ls -l
1.8.1 Description
Provides long listing of files.
1.8.2 Syntax
ls -l
1.9 ls -l -h
1.9.1 Description
Provides size of files in human readable form.
4
1.10 ls -F 1 COMMANDS
1.9.2 Syntax
ls -l -h
1.10 ls -F
1.10.1 Description
Make all the executable with * and directories with /
1.10.2 Syntax
ls -F
5
1.11 ls -a 1 COMMANDS
1.11 ls -a
1.11.1 Description
Show all the file in the present directory with special dot files.
1.11.2 Syntax
ls -a
1.12 cp
1.12.1 Description
Used to copy files and directories
1.12.2 Syntax
cp file1 file2
cp dir1 dir2
6
1.13 rm 1 COMMANDS
1.13 rm
1.13.1 Description
Remove a file.
1.13.2 Syntax
rm filename
7
1.14 rmdir 1 COMMANDS
1.14 rmdir
1.14.1 Description
Used to remove directory.
1.14.2 Syntax
rmdir directory_name
1.15 clear
1.15.1 Description
Used to clear the contents of the terminal.
1.15.2 Syntax
clear
8
1.16 man 1 COMMANDS
1.16 man
1.16.1 Description
View help of the specific command name.
1.16.2 Syntax
man command_name
9
1.17 tree 1 COMMANDS
1.17 tree
1.17.1 Description
Used to list or display the contents of a directory in a tree like format.
1.17.2 Syntax
tree directory_name
10
1.18 locate 1 COMMANDS
1.18 locate
1.18.1 Description
Used to find files using filename.
1.18.2 Syntax
locate [options] file_name
1.19 kill
1.19.1 Description
kill command is used to terminate the process manually.
1.19.2 Syntax
kill [options] pid
11
1.20 less 1 COMMANDS
1.20 less
1.20.1 Description
Views content of a file one scornful at a time. less command is similar to the more command
but faster than more.
1.20.2 Syntax
less filename
12
1.21 who 1 COMMANDS
1.21 who
1.21.1 Description
Used to display who is logged in.
1.21.2 Syntax
who
1.22 top
1.22.1 Description
Used to display resource being used in the system.
1.22.2 Syntax
top
13
1.23 chmod 1 COMMANDS
1.23 chmod
1.23.1 Description
Used to modify file access right.
1.23.2 Syntax
chmod options permissions filename
14
1.24 chown 1 COMMANDS
1.24 chown
1.24.1 Description
It is used to change the user and/ or group ownership of a given file, directory or symbolic link.
1.24.2 Syntax
chown [options] user [:group] file(s)
15
1.25 redirection (>) 1 COMMANDS
1.25.2 Syntax
Command > filename
16
1.26 redirection (») 1 COMMANDS
1.26.2 Syntax
Command >> filename
17
1.27 redirection (<) 1 COMMANDS
18
1.28 piping (|) 1 COMMANDS
1.27.2 Syntax
command < filename
1.28.2 Syntax
command1 | command2
19
1.29 Filters (sort) 1 COMMANDS
1.29.2 Syntax
sort filename
20
1.30 Filters (uniq) 1 COMMANDS
1.30.2 Syntax
uniq filename
1.31.2 Syntax
grep “string” filename
21
1.32 Filters (fmt) 1 COMMANDS
1.32.2 Syntax
fmt filename
22
1.33 Filters (pr) 1 COMMANDS
1.33.2 Syntax
pr filename
23
1.34 Filters (head) 1 COMMANDS
1.34.2 Syntax
head -n filename
(n – number of lines to be printed, default value = 10)
24
1.35 Filters (tail) 1 COMMANDS
1.35.2 Syntax
tail -n filename
(n – number of lines to be printed, default value = 10)
25
1.36 Filters (tr) 1 COMMANDS
1.36.2 Syntax
tr [:lower:] [:upper:]
26
1.37 Job control (ps) 1 COMMANDS
1.37.2 Syntax
ps
1.38 su
1.38.1 Description
Temporarily become super user. It is used to switch from one user to another.
1.38.2 Syntax
su username
1.39 alias
1.39.1 Description
It lets the user to give names of his/her choice to a command or sequence of commands.
1.39.2 Syntax
alias alternatename=command
27
1.40 df 1 COMMANDS
1.40 df
1.40.1 Description
The df command shows the size used and available space on the mounted file system of your
computer. Human readable (-h) option displays the sizes in mb or gb instead of bytes The
exclude (-x) option allows you to tell df to disount filesystems you are not interested in.
1.40.2 Syntax
df [options] filename
28
1.41 diff 1 COMMANDS
1.41 diff
1.41.1 Description
Compares two text files and shows the difference between them. The -y (side by side) option
shows the line differences side by side The -w (width) option lets you specify the maximum line
width to use to avoid wraparound lines The suppress-common-lines prevents diff from listing the
matching lines, letting you focus on the lines which have differences.
1.41.2 Syntax
diff [options] filename1 filename2
29
1.42 echo 1 COMMANDS
1.42 echo
1.42.1 Description
It prints the string of text to the terminal window.
1.42.2 Syntax
echo “string of text”
30
1.43 find 1 COMMANDS
1.43 find
1.43.1 Description
Used to track down files that the user know exists but forgot its path.
1.43.2 Syntax
find startlocation -name *filename*
1.44 free
1.44.1 Description
Gives a summary of memory usage with computer. -h option provides human friendly numbers
and units.
1.44.2 Syntax
free option
1.45 groups
1.45.1 Description
It tells which group the user is a member of
31
1.46 gzip 1 COMMANDS
1.45.2 Syntax
groups username
1.46 gzip
1.46.1 Description
Used to compress the files. By default, it removes the original file and leaves you with the
compressed version. To retain both, use -k (keep) option.
1.46.2 Syntax
gzip option filename
1.47 history
1.47.1 Description
The history command lists the commands you have previously issued on the command line. You
repeat any of the command from history list by typing an exclamation mark(!) and the number
of the command from the history list.
1.47.2 Syntax
history
32
1.48 mv 1 COMMANDS
1.48 mv
1.48.1 Description
Used to move files and directories from directory to directory.
1.48.2 Syntax
mv dir/file dirname
33
1.49 shutdown 1 COMMANDS
1.49 shutdown
1.49.1 Description
Using shutdown with no parameters will shutdown the computer in one minute, shutdown now
command will shutdown computer immediately.
1.49.2 Syntax
shutdown option
34