Basic Linux Commands
1.) pwd
userName@hostName:~# pwd
pwd shows present working directory,
2.) ls
userName@hostName:~# ls
The “Is” command shows files presnt in current directory you are in
use the command “ls -lah” to view the file sizes of all the files in a folder.
3.) cd
userName@hostName:~# cd /var
cd refers to change directory which goes to that particular directory provided after cd command
4.) chmod
userName@hostName:~# chmod 777 -R /var
above chmod command provides full permissions to var folder and its sub-folders recursively
5.) apt-get
userName@hostName:~# apt-get
apt-get command is used to install packages in linux
userName@hostName:~# apt-get install notepad
6.) hostname
userName@hostName:~# hostname
hostname gives your name in the network
userName@hostName:~# hostname -I
gives IP address
7.) df
userName@hostName:~# df
df shows each mounted partition and their used/available space in % and in KBs.
8.) cat
userName@hostName:~# cat
cat command shows contents of a file
9.) nano, vi
userName@hostName:~# nano sample.txt
nano and vi are already installed text editors in the Linux command line.
You can save your files after editing by using the sequence, Ctrl+X, then Y (or N for no).
userName@hostName:~# vi sample.txt
You can save your files after editing by pressing 'esc' button and :wq to save and quit or :q to quit without saving
10.) mkdir
userName@hostName:~# mkdir Softwares
mkdir to create a directory
11.) rm
userName@hostName:~# rm -rf Softwares
The rm command is used to delete files and directories. rm cannot simply delete a directory. “rm -rf” is used to delete a directory forcefully.
12.) touch
userName@hostName:~# touch sample.txt
The touch command is used to create an empty file.
13.) man
userName@hostName:~# man ls
“man ls” shows the page of the ls command.
Help
userName@hostName:~# ls --help
help shows the ways command can be used
14.) cp
userName@hostName:~# cp sample.txt /home/userName/Softwares
The cp command is used to copy files. It takes two arguments, the first one is source location of the file to be copied, the second is destination location where to copy.
15.) mv
userName@hostName:~# mv sample.txt /home/userName/Softwares
The mv command is used to move files. It takes two arguments, the first one is source location of the file to be moved, the second is destination location where to move.
16.) echo
userName@hostName:~# echo helloworld >> sample.txt
“echo” command moves data into text file
17.) zip, unzip
zip command used to compress files into a zip archive, unzip is used to extract files from a zip archive.
18.) tar, untar
To create a tar archive use tar -cvf , -xvf to untar a tar archive
19.) Ctrl+C can be used to stop any command in terminal safely, Ctrl+Z can be used to force stop it.
20.) halt, poweroff, reboot
root@hostName:~# poweroff
To power off or reboot the computer use command sudo halt or poweroff and sudo reboot.