Operating System
Operating System
Question 1: Create a directory in your home directory called projects. In the projects directory, create nine empty
files that are named house1, house2, house3, and so on to house9. Assuming there are lots of other files in that
directory, come up with a single argument to ls that would list just those nine files.
Commands:
mkdir projects
cd projects
touch house {1..9}
Question 2: Make the $HOME/projects/houses/doors/ directory path. Create the following empty files within this
directory path (try using absolute and relative paths from your home directory):
$HOME/projects/houses/bungalow.txt
$HOME/projects/houses/doors/bifold.txt
$HOME/projects/outdoors/vegetation/landscape.txt
Commands:
mkdir -p houses/doors
cd houses
touch bungalow
cd doors
touch bifold
cd ../../
mkdir -p outdoors/vegetation
cd outdoors/vegetation
touch landscape
Question 3: Copy the files house1 and house5 to the $HOME/projects/houses/ directory.
Commands:
cd projects
cp house1 house5 ~/projects/houses
Question 4: Recursively copy the /usr/share/doc/initscripts* directory to the $HOME/
projects/ directory. Maintain the current date/time stamps and permissions.
Commands:
cd ~
cd ../../usr
cd share/doc
sudo touch ininscripts
cp -ra initscripts ~quanhu/projects
Question 5: Recursively list the contents of the $HOME/projects/ directory. Pipe the output to the less command
so you can page through the output.
Commands:
ls -lR /home/projects/ | less
Question 6: Remove the files house6, house7, and house8 without being prompted.
Commands:
cd projects
rm -f house{6..8}
Question 7: Move house3 and house4 to the $HOME/projects/houses/doors directory.
Commands:
cd projects
mv house{3,4} ~/projects/houses/doors
Question 8: Remove the $HOME/projects/houses/doors directory and its contents.
Commands:
rm -rf ~/projects/houses/doors/
Question 9: Change the permissions on the $HOME/projects/house2 file so it can be read and written by the user
who owns the file, only read by the group, and have no permission for others.
Commands:
cd projects
chmod 640 house2
Question 10: Recursively change permissions of the $HOME/projects/ directory so nobody has write permission
to any files or directory beneath that point in the filesystem.
Commands:
chmod -R a-w ~/projects