Working with Directories
Total Page:16
File Type:pdf, Size:1020Kb
working with directories 8.8. practice: working with directories 1. Display your current directory. 2. Change to the ietc directory. 3. Now change to yourhome directorlrui@ 4. Change to the /boot/grub directoqy ruing o'lh, eleven key pressos, 5. Go to the parent directory of the current directory. 6. Go to the root directory. 7. List the contents of the root directory. 8. List a long listing of the root directory- 9. Stay where you are, and list the contents of letc. 10. Stay where you a:e, and list the contents of /bin and /sbin. 11. Stay where you are, and list the contents of -. 12. List all the files (including hidden files) in your home directory. 13. List the files in /boot in a human readable format. 14. Create a directory testdir in your home directory. 15. Change to the /etc directory, stay here and create a directory newdir in your home directory. 16. Create in one command the directories -ldnll&r2/dn3 (dir3 is a subdirectory from dir2, and dir2 is a subdirectory from dirl ). 17. Remove the directory testdir. genmffid:r- 80 8.9. solution: working with directories l. Display your crxrent directory. grd 2. Change to the /etc directory. cd /etc 3. Now change to your home directory using only three key presses. cd (and the enter key) 4. Change to the /booVgrub directory using only eleven key presses. cd /boot/grub (use the t.ab key) 5. Go to the parent directory of the current directory. cd - . (with space between cd and . ) 6. Go to the root directory. cd/ 7. List the contents of the root directory. 1s 8. List a long listing of the root directory. Is -1 9. Stay where you are, and list the contents of /etc. Is /etc 10. Stay where you are, and list the contents of /bin and /sbin. Is /bin /sbin 11. Stay where you are, and list the contents of -. 1s- 12. List all the files (including hidden files) in your home directory. ls -aI - 13. List the files in /boot in a human readable format. LE -Ih /boot 14. Create a directory testdir in your home directory. mkdir -/testdir 15. Change to the /etc directory, stay here and create a directory newdir in your home directory. 81 working with directories cd letc ; rnkdir -/newdir 16. Create in one coilrmand the directories-/dnl/dir2ldir3 (dir3 is a subdirectory from dir2, and dir2 is a subdirectory from dirl ). nrkdir -p -/d,irt/ dir2 / dir3 17. Remove the directory testdir. rmdir testdir 18. If fime permits (or if you are waiting for otler students to finish this practice), use and understand pushd and popd. Use the man page of bash to find information about these commands. man bash * opens the manual /puehd * searehes for pushd n # next (do t,hi.s trro/t.hree times) The Bash shell has two built-in commands called pushd and popd. Both commands work with a common stack ofprevious directories. Pushd adds a directory to the stack and changes to a new current directory, popd removes a directory from the stack and sets the current directory. paulodebianl : / et cS cd,/bia paul@debian7: /bi-ng purbd ,/l.J.b /Llb /biyr paul@debian7 : /1ibg l,ucbd /proc /proc /ltb lbtrr paul@debian? : /procg popd /Lib /bLn pauledebi.an? : /libg popd /bLn 82.