Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
1. Topic : Linux Files, Directories and Basic Commands
(Part- 2)
2. The pwd command is used to display
the location of the current working
directory.
Syntax:
pwd
Linux Files, Directories and Basic Commands
1. pwd
3. The touch command is used to
create empty files.
Syntax:
touch <filename>
We can create multiple empty files
by executing it once as shown in
figure:
touch demo3.txt demo4.txt
Linux Files, Directories and Basic Commands
2. touch
4. The finger command is a user
information lookup command which
gives details of all the users logged in.
It provides details like login name,
user name, idle time, login time, and in
some cases their email address even.
Syntax:
$ finger <username>
Example: $finger tempusr gives all the
details of tempusr as shown in figure.
Linux Files, Directories and Basic Commands
3. finger
5. The passwd command is used to
create and change the password for a
user.
Syntax:
sudo passwd <username>
Here we changed the password of
tempusr as shown in figure.
Linux Files, Directories and Basic Commands
4. passwd
6. The date command is used to display
date, time, time zone, and more.
Syntax:
$ date
Linux Files, Directories and Basic Commands
5. date
7. The head command is used to display the
content of a file. It displays the first 10 lines
of a file.
Syntax:
head <filename>
Here in the figure, the cat command shows all
the content of the demo2.txt file whereas the
head command shows only the first 10 lines.
Linux Files, Directories and Basic Commands
6. head
8. The tail command is used to display the
content of a file same as the head command.
It displays the last 10 lines of a file.
Syntax:
tail <filename>
Here in the figure, the cat command shows all
the content of the demo2.txt file whereas the
tail command shows only the last 10 lines.
Linux Files, Directories and Basic Commands
7. tail
9. The cut command is used to select a specific
column of a file.
Syntax:
cut -d(delimiter) - f(columnNumber) <fileName>
Here,
• -d is used as a delimiter which can be a
space, slash, hyphen, or anything else.
• -f is used to specify the column number.
As shown in the figure with the delimiter as a
hyphen (-) and column number 2, we got the
desired output.
Linux Files, Directories and Basic Commands
8. cut
10. The sort command is used to sort files
in alphabetical order.
Syntax:
sort <file name>
Here as shown in figure , sort
command sorts all the contents of
demo.txt in alphabetical order.
Linux Files, Directories and Basic Commands
9. sort
11. The 'grep' stands for "global regular expression
print." It is useful for searching the content from a
file.
Syntax:
command | grep <searchWord>
As shown in the figure when we search for 5 using
the command $ cat demo.txt | grep 5 in the
demo.txt file it gives the desired output.
Linux Files, Directories and Basic Commands
10. grep