Linux Exam Sample Questions Help for ICT480 1. 2. Login to tty1 as root with a password of “redhat”.

Create a file called “test1” and save it with the following contents and format: Dear Mr. Smith: Please send my refund to: Student Success NAIT 11762-106 Street Edmonton, AB T5G 2R1 <YOURFIRSTANDLASTNAME> (Print your first and last name here in all CAPS: e.g. JAMES MUNROE) Marks will be deducted for spelling, punctuation and format errors. Create the content exactly like you see it above. (4) #vi test1 Press I to insert text When done with text press (esc) Press shift ; Type wq to save (w is save and q is quit) 3. Create a new user named “tom” with a home directory of the same name and a UID of 824 (using the proper options). Create a password for the new user of “redhat”. Use the command line to open and view the files needed to verify this information. (5) #man useradd #useradd –u 824 tom #passwd tom #redhat To verify this look @ home directory to see new user #cat /etc/passwd 4. Change the ownership of the test1 file so that fred is both the user and group owner. Move test1 to the home directory of the fred user. (3)

#ls –l test1 #clear ( not necessary but clears the terminal window) #chown tom:tom test1 -this changed ownership to tom #ls –l test1

#mv test1 /home/tom -move file to tom’s home directory # ls 5. Login to tty2 as tom (stay logged in to tty1 as the root user). Change the permissions on the test1 file so that fred has read and write user permissions but the group and other categories have read only permissions. (2) Log onto tty2 with Ctrl+Alt+f2 -currently rw r r Ex. of how{ #chmod 764 test1 -changing to rwx rw r to change { #ls –l 7 6 4 permissions { after this it should show as green 111 110 100 6. Create a hard link called test2 that links to the test1 file. (1) #ln test1 test2 #ls –li -to separate file using some inod number ex. Test1 66993 Test2 66993 # cat test2 -should be the same as test1 7. Create a symbolic link called test3 that links to the test1 file. (1) #ln –s test1 test3 #ls –li -show test3 is a shortcut to test1 and inod values are different Create a directory called “testfiles”. Move all the test files into the testfiles directory. (2) #mkdir testfiles #mv test? testfiles -? Is a wildcard moves all test with a number behind it and moves to testfile folder 9. Send an email to the root user with the subject line “Super user rules”. (1) # mutt -hit enter to create mail To:root Subject: Super user rules Open vi Write save and quit (previously done) Hit y to send message 10. Change back to tty1 (logged in as the root user). Now go to tty1 (Ctrl+Alt+f1) #mutt -see message Now if you can’t see it check service configuration in tty7 and make sure mail is running 8.

11.

Run the command (as the root user) that shows a listing of all the test files that includes their inode numbers, permissions and file types. (3)

#ls -li 12. Using the proper command, lock the account of the user fred and open the file where his MD5-encrypted password lives. (2) Use the usermod command to modify account #man usermod Find two options Capital L (locks) and Capital U (unlocks) #usermod –L tom #cat /etc/shadow -tom now has his password with a ! in front If you try to login it will say login incorrect Run the command that shows only the first 6 lines of the contents of the file test1. Next run the command that shows only the last 3 lines of the contents of the test1 file. (2) #cd testfiles #cd head –n 6 test1 -shows first 6 lines # tail –n 3 test1 -shows last three lines 14. Run the command that displays what is in your PATH variable. (1) Tty1 #echo $PATH -see path long #ifconfig #echo $PATH -see path short #ifconfig (doesn’t work now) #locate ifconfig 15. #set 16. Run the command that lists all environment variables in the BASH shell. (1) Run the command that lists all exported environment and user-defined variables in the shell. (1) 13.

#env -show all variable that are exported to child shells 17. Using a page-by-page command, open the file that shows you general system info logged at boot time, including daemons loaded at startup and other important system info since startup. (2) All log files stored /var/log

#cd /var/log #ls -all files log #less messages -scroll through file # less messages >~/bootlog #cd # cat /bootlog 18. Run the command that shows info about all your NICs, including your IP addressing and the loopback info. (1) #ifconfig 19. Run the command that changes the name of your computer and change your computername to <yourfirstname>. (1)

#hostname #hostname <your first name> #hostname (check to see it changed) 20. Display the contents of the file that lists your DNS servers. (1) #cat /etc/resolv.conf 21. Using a page-by-page command, display the contents of the file that configures the order of name resolution. (1) #less /etc/hosts 22. #pwd Display the name of the directory you are sitting in. (1)

23. Turn on routing. (hint: ip_forward) (2) #cd /etc #cat /proc/sys/net/ipv4/ip_forward #echo 1 > /proc/sys/net/ipv4/ip_forward # cat /proc/sys/net/ipv4/ip_forward - places a one in the file to enable ip routing! 24. Run the sleep command for 300 seconds in the background. (1)

#sleep 10 & - to show job number and process id #ps 25. Key in the command you would use if you had to create a new file system on a floppy drive. (1) #mkfs –t ext2 /dev/fd0 -creates file system (if you want to mount) #mount /dev/fd0 /mnt/floppy #cd /mnt/floppy #ls -shows floppy disc save 26. What is the command you would use if you had to create a new partition (no options). (1) Not in exam 27. Edit and save the configuration file that holds the scripts for your first (active) Ethernet device so that your ip address will be set to 10.1.100.xx with subnet mask of 255.255.0.0 and a gateway of 10.1.100.254 (where xx is your monitor number). Activate the changes. (Hint: restart your network daemon (5) #vi /etc/sysconfig/network-scripts/ifcfg-ethx -change settings and “restart the network daemon” #ifdown ethx #ifup ethx 28. Re-direct the output of the command that shows you the time to a file called “date1”. (2) #date > date1 ( its directing the date to file date1 # cat date1 -dare and time 29. Change the time on your system so that it reads 24 hours later than now, and then re-direct the output of the command that shows you the time to a file called “date2”. (3) #date 0701040095 - that example is July (7th month) 1st(01) 4 am and 0095 for 1995 or whatever year its running at # date > date2 30. Show who is logged in to the system. (1) #who 31. Using grep, search for the string “my refund” in the test1 file. (2) #cd /home/tom/testfiles #ls

#cat test1|grep “my refund” (This search for what line it is) 32. How many files and or directories are there in the /dev directory that begin with the letter “p” and contain a total of 5 characters? Write down the command you used in the space provided.(4)

#cd /dev #ls #ls p???? (5 characters total ) #ls p???? |wc -l 33. How many directories are there in the /dev directory? Write down the command you used to determine this in the space below.(3) #ls –l (make sure you are in dev directory #ls –l | grep ^d |wc -l 34. Create a command/script file that clears the screen, outputs a long listing of your home directory, and displays only the current time (not the date). Call it “goodtimes”. Put the file in a directory called bin in your home directory.

#cd #mkdir bin #ls (it should be there) #cd bin #vi goodtimes (add the following to the beginning of the scripts #! /bin/bash Clear ls -l /root date | cit =d ‘ ‘ –f5 exit save and quit the vi #ls –l #chmod 744 goodtimes #goodtimes 35. Write down the command you would use to display the number of symbolic links in the /etc directory. (3)

#cd /etc # ls –l |grep^l |we -l 36. Pipe the output of the date command through cut to select the month field. (4) #just adiffer field

37.

The /etc/passwd file contains the list of all users defined on the system, write down the command you would use to display the number of users defined on your system. (3) #cat /etc/passwd/wc –l #cat /etc/grep/bin/bash/wc -l 38. Use the find command to find a file called “nsswitch.conf” (2) #find / -name nsswitch.conf 39. Use the locate command to find a file called “lmhosts” (1) # locate lmhosts 40. Use the which command to find a file called “ifconfig” (1) #which ifconfig

IF you encounter any difficulties try the man command #man -type whatever you are having difficulty with in the underscores Link to linux commands http://www.ss64.com/bash/ GOOD LUCK!

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.