Coconut Catalogue
coconutc.com

3) Linux

STEP 1#

Opening terminal

There are 2 ways of doing this:-

  1. Top left corner terminal icon.

  2. Press Alt+Ctrl+T.

terminal

pi is the name of the user and raspberry is the name of computer in pi@raspberry:~$.
~(tilde) tells that we are in home directory and it gets replaced by /(slash) in other directories.

STEP 2#

Different Linux Commands in terminal.
First command is ls command. It shows the list of all directories and files present in current directory. ls -a show all files and directories including hidden. Assume Pictures folder contains images such as image1.jpg, image2.gif and T_img(directory).

pi@raspberry:~$
pi@raspberry:~$ ls
Desktop Download Music Public
Videos Documents Pictures 
pi@raspberry:~$ ls Pictures
image1.jpg image2.gif
T_img
			

Second command we are going to discuss is pwd. It tells us the present directory.

pi@raspberry:~$
pi@raspberry:~$ pwd
/home/pi
			

Third is cd. We can use it to change directories. cd .. is used to go to parent directory. cd / brings us to root directory no matter where ever we are.

pi@raspberry:~$
pi@raspberry:~$ ls
Desktop Download Music Public
Videos Documents Pictures 
pi@raspberry:~$cd Pictures
pi@raspberry:~/Pictures$
pi@raspberry:~/Pictures$ cd ..
pi@raspberry:~$
pi@raspberry:~$cd Pictures/T_img
pi@raspberry:~/Pictures/T_img$
pi@raspberry:~/Pictures/T_img$cd ../..
pi@raspberry:~$
pi@raspberry:~$ cd /
pi@raspberry:/$
pi@raspberry:/$ ls

bin 	dev 	initrd.img 	lost+found 	opt 	run 	srv 	usr
boot	etc	lib		media		proc	sbin	sys	var
cdrom 	home 	lib64 		mnt 		root 	snap 	tmp 	vmlinuz
			

Fourth command we are going to discuss is mv. It is used to move files from one place to another. Its format is
mv file destination

pi@raspberry:~$
pi@raspberry:~$ ls Desktop
abc.txt
pi@raspberry:~$ mv Desktop/abc.txt ../Pictures
pi@raspberry:~$ ls Desktop
pi@raspberry:~$ ls Pictures
abc.txt emma_watson.jpg
			

Fifth one is cp. It is used to copy files from one place to another. Its format is
cp file destination

pi@raspberry:~$
pi@raspberry:~$ ls Desktop
pi@raspberry:~$ ls Pictures
abc.txt emma_watson.jpg
pi@raspberry:~$ cp Pictures/abc.txt Desktop
pi@raspberry:~$ ls Desktop
abc.txt
pi@raspberry:~$ ls Pictures
abc.txt emma_watson.jpg
			

RASPBIAN comes with 2 text editors which can be used to edit and create files. They are nano and leafpad. Using these commands will edit the file if it exists in the directory, otherwise it will create new file in the directory. A new window is prompted where you edit the file and close it after saving.

pi@raspberry:~$
pi@raspberry:~$ ls Desktop
pi@raspberry:~$ leafpad cruise\ missile.txt
pi@raspberry:~$ ls Desktop
cruise missile.txt
			

rm command is used to remove(delete) files from a directory.

pi@raspberry:~$
pi@raspberry:~$ ls Desktop
cruise missile.txt
pi@raspberry:~$ rm Desktop cruise\ missile.txt
pi@raspberry:~$ ls Desktop
pi@raspberry:~$
			

mkdir command is used to make a new directory and rmdir is used to remove a directory. Just make sure that direcory is empty before using rmdir otherwise the it will not work.

pi@raspberry:~$
pi@raspberry:~$ mkdir Desktop/fury
pi@raspberry:~$
pi@raspberry:~$ ls Desktop
fury
pi@raspberry:~$ rmdir Desktop/fury
pi@raspberry:~$ ls Desktop
pi@raspberry:~$
			

Special Control Keys

Ctrl+A: Moves the cursor to beginning of the line.
Ctrl+E: Moves the cursor to end of the line.
Ctrl+Z: Used to end certain running process in terminal.
Ctrl+C: Kills current running program.
Ctrl+D: Exits the shell.
TAB key is used fo autocompletion of command.
upper arrow key is used to rewrite the previous written command.


Updating and Installing

sudo is prefixed before a command to execute that command as a super user. apt-get is used for updating or installing softwares.
sudo apt-get update updates all the existing softwares in Operating System.
sudo apt-get update software will update a particular software.
sudo apt-get install software installs the specified software.


×