You are on page 1of 3

LINUX Assignment

Ex-4
Archive the contents of your home directory using tar. Compress the tar file with gzip. Now uncompress and unarchive the .tar.gz file using cat, tar and gzip on one command line.

tar -cvf file1.tar /home/tejas gzi file1.tar g!nzi fil1.tar.gz tar -xvf file1.tar tar -zcvf la".tar.gz la" gzi -# la".tar.gz $ tar -xf la".tar $ cat la" /hello.txt
1. Use find to compile a list of all directories in the system, redirecting the output so that the list of directories ends up in a file called directories.txt and the list of error messages ends up in a file called errors.txt. fin# / -t" e f % #irectories.txt &%error.txt 2. ry the command sleep !. "hat does this command do# Answer$ his command delays of ! seconds to the terminal. %. &un the command in the 'ac(ground using ). Ans'er( slee 1) * *. &un sleep 1! in the foreground, suspend it with Ctrlz and then put it into the 'ac(ground with 'g. ype +o's. ype ps. ,ring the +o' 'ac( into the foreground with fg. Answer$

!. &un sleep 1! in the 'ac(ground using ), and then use (ill to terminate the process 'y its +o' num'er. &epeat, except this time (ill the process 'y specifying its -./. Answer$ 0. &un sleep 1! in the 'ac(ground using ), and then use (ill to suspend the process. Use 'g to continue running the process. Answer$ sleep 1! ) (ill sleep (ill 1cont 2*! 33 it4s command for resuming (illed process 5. 6tartup a num'er of sleep 07 processes in the 'ac(ground, and terminate them all at the same time using the p(ill command. Answer$

8.Use ps, w and top to show all processes that are executing.

2. Use ps ae9 to display the process hierarchy. :oo( for the init process. 6ee if you can identify important system daemons. Can you also identify your shell and its su'processes#

17. com'ine ps fae with grep to show all processes that you are executing, with the exception of the ps fae and grep commands. Ans'er( s -fae + tejas 11. 6tart a sleep %77 process running in the 'ac(ground. :og off the server, and log 'ac( in again. :ist all the processes that you are running. "hat happened to your sleep process# Now repeat, except this time start 'y running nohup sleep %77. 12. ;ultiple +o's can 'e issued from the same command line using the operators <, )) and ==. ry com'ining the commands cat nonexistent and echo hello using each of these operators. &everse the order of the commands and try again. "hat are the rules a'out when the commands will 'e executed# c# la" $ cat hello.txt c# la" ** cat hello.txt c# la" ++ cat hello.txt 1%. "hat does the xargs command do# Can you com'ine it with find and grep to find yet another way of searching all files in the 3home su'directory tree for the word hello#
Ans'er( ,!il# an# exec!te comman# lines from stan#ar# in !t. fin# /home + xargs gre hello

1*. "hat does the cut command do# Can you use it together with w to produce a list of login names and C-U times corresponding to each active process# Can you now >all on the same command line? use sort and head or tail to find the user whose process is using the most C-U# ' + c!t -c1-)-).-./ % ne'.txt + sort -r ne'.txt + tail -0 ne'.txt

You might also like