You are on page 1of 1

Lab 0: Familiarity with the Linux command line

1. Create a text file named personal with the following information, each on a different line.
Your name, your roll number, your date of birth, your hometown.
Create a second file called courses which lists five courses you are taking this semester.
Create a third file called movies which lists the name of five movies you have seen.
1. Using the cat command, display the contents of each file.
2. etermine the number of lines in each file. Use wc.
!. Using redirection, concatenate personal and courses into a single file called both.
"ind the number of lines of both.
#. $ppend movies at the end of both.
2. Create a directory called dir1. Copy personal and movies into dir1. %nside dir1,
rename both these are personal-1 and movies-1. Copy the entire dir1 directory into a
new directory called dir1copy.
!. Change to the directory dir1copy and create a text file called hobbies. &ove back to your
home directory. Using absolute pathnames, copy hobbies into the directory dir1.
#. 'emove the directory dir1copy. Use rmdir command.
(. )ist contents of your home directory. *hich is the file which was last accessed+ *hich file was
first created and when+ Use touch and change the access time of the second file. ,ow which
is the file last accessed+
-. )ist the contents of the /etc directory. *hich file was last accessed and when+
.. /utput the last ( lines of the /etc/passwd file. 0hen output the first # lines of the same file.
Use head and tail.
1. )ist of contents of /etc directory, and use less to display one screen of output at a time.
2. isplay disk space usage using df command. 3ow will you display the filesystem type and
human4readable format+
15. Use seq and shuf to generate a random se6uence of numbers. 7ipe into wc to determine the
number of lines.
11. 8ort the above se6uence using sort. Use the -n flag for numeric sort.
12. Create a text file having three columns9 rollnumber, name, marks. Use shuf to generate a
random permutation of the entries. ,ow sort based on the marks :use -k flag.; Use head to
print the records with the top three marks.
1!. Use seq and shuf to generate random se6uences of length 25, !5 and 155. 'edirect these to a
single file. 3ow many lines are present+ Use uniq to remove repeated entries. 3ow many lines
are present now+

You might also like