You are on page 1of 16

Module.No # 1 Exercise 1.1 : a.

Login

b. Logout

c. Log in again. Open a terminal window, to start a shell.

d. Exit from the shell; the terminal window will close

e. Start another shell. Enter each of the following commands in turn.

Date

Whoami

Hostname

Uname

Uptime

Exercise 1.2 : a. Use the lscommand to see if you have any files.

b. Create a new file using the cat command. c. Use ls command again to verify that the new file exists.

d. Display the contents of the file.

e. display the file again , but use the cursor keys to execute the same command again without having to re type it.

Exercise 1.3 : a. Create a second file. Call it secret-of-the-universe, and put in whatever content you deem. b. Check its creation with ls command.

c. Display the contents of this file. We minimize the typing by pressing up key and get the same command and execute that.

Exercise 1.4 : a. copy secret-of-the-universe to a new file called answer.txt. Use tab to avoid typing the existing files name in full.

b. Now copy hello.txt to answer.txt. Whats happened now? c. Delete the original file, hello.txt. d. Rename answer.txt to message. e. Try asking rm to delete a file called missing. What happens?

f. Try copying secret-of-the-universe again, but dont specify a file to which to copy. What happens now?

Module 2 1. (a) Use the pwd command to find out what directory you are in.

(b) We are already in the home directory. (c) cd to visit the root directory, and list the files there. You should see home among the list. name@name-virtualbox:~$ cd .. name @name -virtualbox:/home$ cd .. name @name -virtualbox :/$ ls bin dev initrd.img lost+found opt sbin sys var boot etc initrd.img.old media proc selinux tmp vmlinuz cdrom home lib mnt root srv usr vmlinuz.old (d) Change into your home directory to confirm that you have gotten back to where you started.

2. a. Create a text file in your home directory called shakespeare, containing the following text: Shall I compare thee to a summers day? Thou art more lovely and more temperate. b. Rename it to sonnet-18.txt. c. Make a new directory in your home directory, called poetry. d. Move the poem file into the new directory.

e. Try to find a graphical directory-browsing program, and find your home directory with it. You should also be able to use it to explore some of the system directories.

should also be able to use it to explore some of the system directories. f. Find a text editor program and use it to display and edit the sonnet.

3. (a) nam@name e-virtualbox:~$ ls ../ ../usr/share (b) name@name -virtualbox:/$ cd ../../usr/share name@name -virtualbox::/usr/share$ pwd /usr/share name@name -virtualbox:/usr/share$ ls name@name -virtualbox:/usr/share$ doc (c) Parent Directory: name-virtualbox:/usr/share$ ls .. The directory above it : name@name -virtualbox:/usr/share$ ls .. / .. (d) name@name -virtualbox:/usr/share$ echo /home/name By writing this command, it prints the home directory (e) name@name -virtualbox:/usr/share$ cat ~/sonnet-18.txt Shall I compare three to a summer's day? Thou art more lovely and more temperate. 4. (a) name@name -virtualbox:/$ hostname name @name -virtulbox (b) name@name -virtualbox:/$ man

What manual page do you want? name @name -virtualbox:/$ man hostname

Command to view the IP address: c. Usethelocatecommandtofindfileswhosenamecontainsthetexthostname.Whichofthefilenam es printed contain the actual hostname program itself? Try running it by entering the programs absolute path to check that you really have found it.

5. (a)

(b)

(c) name@name -virtualbox:~$ cat>sonnet-29.txt When in disgrace with fortune and men's eyes I all alone beweep my outcast state. (d) name@name -virtualbox:~$ cd Poetry name@name -virtualbox:~/Poetry$ cat*.txt Shall I compare three to summers day? Thou art more lovely and more templete. When in disgrace with fortune and men's eyes I all alone be weep my outcast state. (d) name@name -virtualbox:~$ cd Poetry name@name -virtualbox:~/Poetry$ cat*.txt Shall I compare three to summers day? Thou art more lovely and more templete. When in disgrace with fortune and men's eyes I all alone be weep my outcast state. (e) name@name -virtualbox:~$ cd Poetry name@name -virtualbox:~/Poetry$ rm * name@name -virtualbox:~/Poetry$ ls name@name -virtualbox:~$ rmdir Poetry name@name -virtualbox:~$ ls

Module 3

1. (a)

(b) name@name -virtualbox:~$ df --human-readable Filesystem Size Used Avail Use% Mounted on /dev/sda1 7G 21G 5G 31% / none 368M 648K 368M 1% /dev none 368M 224K 368M 1% /dev/shm none 368M 96K 368M 1% /var/run none 368M 0 368M 0% /var/lock (c ) name@name -virtualbox:~$ sh $ We have entered into bash shell. $ exit name@name -virtualbox:~$ By writing exit, we came out of the bash shell. 2. (a)

(b) name@name -virtualbox:~$ for textfiles in *.txt; do echo; done message secret-of-the-universe.txt sonnet-18.txt (c)

3. (a) find -type d find -type f (b) name@name -virtualbox:~$ locate bashbug /usr/bin/bashbug /usr/share/man/man1/bashbug.1.gz (c ) Its like -name but the match is not case sensitive.

Module 4

1. (a)

(c ) With last : name@name -virtualbox:~$ last name pts/0 :0.0 Fri Sep 9 16:46 still logged in name pts/1 :0.0 Fri Sep 9 16:45 - 16:46 (00:00) name pts/0 :0.0 Fri Sep 9 16:20 - 16:46 (00:25) name tty7 :0 Fri Sep 9 16:20 still logged in wtmp begins Fri Sep 2 09:07:26 2011 Reversing with tac: name tty7 :0 Fri Sep 9 16:46 still logged in name pts/0 :0.0 Fri Sep 9 16:45 - 16:46 (00:00) name pts/0 :0.0 Fri Sep 9 16:20 still logged in wtmp begins Fri Sep 2 09:07:26 2011 Piping the output with less: name pts/0 :0.0 Fri Sep 9 16:45 still logged in name tty7 :0 Fri Sep 9 16:46 still logged in wtmp begins Fri Sep 2 09:07:26 2011 (d)

does work multiple times on the same line. name@name -VirtualBox:~$ sed -e 's/enviroment/environment/'g test.txtln1 1. Look in for checking the spelling envoiroment envoironment 2.correction needed 3.correct it with sed 2.

(c) name@name -VirtualBox:~$ cat/bin/ls | less output in hexadecimal name@name -VirtualBox:~$ od -t x1z/bin/ls | less 3.

(b) name@name -VirtualBox:~$ cat split_*>./my_ls

Module 5

1. a. Use cd to go to your home directory, and create a new directory there called dog. b. Create another directory within that one called cat, and another within that called mouse.

c. Remove all three directories. You can either remove them one at a time, or all at once. name@name -VirtualBox:~$ rmdir mouse name@name -VirtualBox:~$ rmdir cat name@name -VirtualBox:~$ rmdir dog e. Try creating the dog/cat/mouse directory structure with a single command. name@name -VirtualBox:~$ mkdir p dog/cat/mouse 2. a. Copy the file /etc/passwd to your home directory, and then use cat to see whats in it.

c. Make a directory called programs and copy everything from /bin into it. name@name -VirtualBox:~$ mkdir programs name@name -VirtualBox:~$ cp /bin/* programs d. Delete all the files in the programs directory. name@name -VirtualBox:/programs~$ rm * e. Delete the empty programs directory. name@name -VirtualBox:~$ rm r programs 3. a. The touch command can be used to create new empty files. Try that now, picking a name for the new file: b. Get details about the file using the ls command:

c. Wait for a minute, and then try the previous two steps again, and see what changes. What happens when we dont specify a time to touch?

d. Try setting the timestamp on the file to a value in the future.

. e. When youre finished with it, delete the file. . name@name -VirtualBox:~$ rm baked-beans

You might also like