37 terms

Linux Practice Exercises

STUDY
PLAY
echo Jon > friends.txt
echo Jenna >> friends.txt
echo Sara >> friends.txt
1. Create a file friends.txt with a list of names of three of your friends on separate lines.
cat friends.txt
2. Display the contents of friends.txt on the console.
mv friends.txt hommies.txt
3. Rename file friends.txt to homies.txt.
cp homies.txt humans.txt
4. Make a copy of homies.txt under the name humans.txt
ls h*.txt
5. List all files whose name begins with letter 'h' and ends with extension txt.
ls -l humans.txt
6. Write a command that will tell you how many bytes
are taken up by file humans.txt.
echo Jeep > cars.txt
echo BMW >> cars.txt
echo Van >> cars.txt
echo Car >> cars.txt
echo Truck >> cars.txt
7. Create file cars.txt with a list of 5 brands of cars
on separate lines.
ls -l cars.txt
8. Check how many bytes are taken up by the file.
cp cars.txt /tmp
9. Copy the file cars.txt into directory /tmp
ls /tmp/*.txt
10. List all files with extension *.txt in directory /tmp
and verify that the file was copied properly.
mv /tmp/cars.txt /tmp/vehicles.txt
11. Without leaving your home directory rename file cars.txt
located in /tmp to vehicles.txt in /tmp
cat cars.txt humans.txt > carsandhumans.txt
12. Concatenate the contents of files 'cars.txt' and 'humans.txt'
into file 'carsandhumans.txt'
mkdir series3
13. Create directory 'series3'.
mv cars.txt humans.txt series3
14. Move files cars.txt and humans.txt into directory 'series3'
ls -l series3
15. List contents of 'series3' directory in details.
cp -r/home/hope/files
16. Search the web or use manual page by issuing: man cp
on how to copy a directory with all its contents.
cp -r series3/ series3copy
17. In one commandls make a copy of directory 'series3'
and all its contents under name 'series3copy'.
ls -l series3
ls -l series3copy
18. List contents of series3 and series3copy directories
in two separate commands to verify copying was successful.
cd
19. How do you get to the home folder from anywhere
cd ../../etc
20. Change directory to /etc but using RELATIVE path only, in one command.
cat passwd
21. Display the contents of 'passwd' file on the screen.
less passwd
22. Display the contents of 'passwd' file on the screen interactively (so you can search, scroll up and down)
cd ../var/log
23. Change directory to /var/log but using RELATIVE path only, in one command (assuming you're in etc)
Less syslog
cat syslog | less
24. Display the contents of 'syslog' file on the screen interactively (so you can search, scroll up and down)
cp syslog ~/sytemlog.txt
25. Copy file 'syslog' to your home directory under the name 'systemlog.txt' using path relative to home directory, in one command.
cp syslog ~/systemlog.txt
26. Copy file 'syslog' to your home directory under the name 'systemlog.txt' using path relative to home directory, in one command.
1 - Global config files
2 - Scripts
3 - Text files
27. What is the contents or purpose of /etc? - Three things
Changeable data such as email, printer spooler, system logs, databases,
28. What is the contents or purpose of /var? - 4 examples
It's a directory that contains home directories
29. What is the contents or purpose of /home?
Temporary mountable files, mount point
Manually mounted shares, partitions
30. What is the contents or purpose of /mnt?
/bin
/sbin
/usr/bin
/usr/sbin
31. Give a list of 4 main directories that contain executable files.
/var/log/syslog
32. What is the path to the main/default log file used by the operating system?
/boot
33. Which directory contains file with Linux kernel?
/lib
34. Which directory contains kernel modules?
Mount point for removable media
35. What is the purpose of /media directory?
/etc/passwd
36. Give path (including file name) to file that contains the list of all users defined on the system.
Every day all files that haven't been accessed in a week will be removed automatically.
37. Do you have to remove files/directories you created in /tmp? Yes or no and explain why.