Vk 35 Kotitehtävät 2

Command line exercises
1. Make your self a list of most common commands.

-pwd – prints the current directory
ls – lists all the files and their permissions in a given directory
cat filename – prints the content of the file in the shell, works also as the cp -command
vi filename – creates a file with the name “filename” and opens the text editor for editing file
cd – changes the current directory
find – find files in any specified directory
rm filename – removes a file
apt-get – downloads and updates programs
sudo – allows the user to run a command as the superuser
systemctl – checks daemons and their status (active/inactive)
man/info – opens up a command’s manual or info page, also –help
2. Which command lists files in directory /usr/bin?

– ls /usr/bin/  or ls /usr/bin/ -lha, -a..
3. Previous command prints a long list. How can you browse the list?

-ls -a | less(more)
4. a. Which one command moves you to /usr/lib?

-cd /usr/lib
b. Which one command moves you back to your home directory?

-cd —
5. Which command searches the whole computer for file syslog?

-sudo find / -type f -name syslog ( / means root so this searches the whole system)
6. How can you get help in using command grep?

-man grep or info grep or grep –help
7. Copy file /etc/popularity-contest.conf to your home directory without typing the whole file name (use auto completion).

-cp /etc/pop… (press TAB for autocompletion of the file name. If you press twice shell shows every file in the directory that starts with pop.. )
8. What is your home directory?

-/home/otso or  in server /home/master
9. Copy /etc/services to your home directory

-sudo cp /ect/services ~/home/otso/
10. Copy directory /etc/X11 to your home directory. (Whole directory with contents)

-cp -r /etc/X11 (case sensitive) ~    -r option means directory here
11. Find commands that list devices (block, USB, …).

lsblk – list the block devices (i.e. drives)
lspci – list the pci devices.
lsusb – list the USB devices.
lsdev – list all the devices.

-sudo fdisk -l -list all the disks


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s