Commands of Linux
types of commands :
>> built-in Linux(shell) : bash supports several commands internally.
>> An executable program : programs can be compiled binaries as C++ program.
>> shell function : These are miniature shell scripts incorporated into the environment.
>> An alias : commands built from other commands.
Ls => to show list of folders.
Ls -l => to show list of folders with details (permissions).
Ls -l / folder-name => to show properties of folder.
ls -a => to show the list from folders with hidden files.
Ls -s => to print the allocated size of each file or folder.
Pwd => (print working directory) to print name of your current position
path.
who => to show who is logged on and date and time of logged in ( usually
used in server).
whoami => to print effective user id or name.
w => to show who is logged on and what they are doing.
date => to show the date and time.
cal => to show the calendar of current year.
clear => used to clear the terminal screen.
exit => to close the terminal screen.
uname => to show only the name of operating system.
uname -a => to show the information about operating system.
uptime => to show the current time.
history => to show all commands you already applied in terminal screen.
history -c : to clear all commands from history.
command --help => to show information about command.
man command=> is an interface to the system reference manuals (To
clarify what the command do).
Whatis command => display one-line manual page descriptions.
hostname => to show or set the system ‘s hostname.
hostname -i => to show the addresses for the hostname.
df => to report file system disk space usage (size used in hard disk).
poweroff => used to close linux operating system.
last => show a listing of last logged in users.
file name => to determine file type.
Commands of dealing with folder :-
cd name-of-folder => to enter the folder by its name.
cd .. => to get out from current folder to parent folder.
cd ../.. => to get out from current folder to parent folder of parent folder.
mkdir folder-name ==> to make a new folder with the name of folder.
mkdir -p folder-name1/ folder-name2/ folder-name3 ==> to make a new
folder with name1 and contain folder with name2 and contain folder with
name3.
rmdir folder-name => delete folder with name but not embedded folder.
rmdir -r folder-name => delete embedded folder with name.
rm -r name => delete the embedded folder (or file) with name.
mv folder(x) folder(y) => move folder(x) to inside folder(y).
cp -r folder(x) folder(y) => copy folder(x) and paste inside folder(y).
mv folder(x) ../ => to remove the folder from position folder to parent
folder (previous folder).
mv folder(x) ../.. => to remove the folder from position folder to parent
folder of parent folder(previous folder).
mkdir . folder(x) => to make a new hidden folder with name x.
Commands to file :-
touch file.name(x) => to make file (like notepad )with name x
cat file.name(x) ==> to show the information in file x.
nano file.name(x) => to open file and write data in there.
open file-name(x) => to open file x and write data in there.
mv file-name(x) new-name(y) => to change the name(x) of file to another
name(y).
head file-name(x) => to show the first ten lines in file x.
tail file-name(x) => to show the last ten lines in file x.
grep word file-name(x) => to search for word in file x.
Types of Permission : read write execute (drwxrwxrwx)
>> d : refer to directory (folder)
>> - : refer to file.
>> l : refer to link.
>>Directions of Permission : user /
group of owner / other users.
>> first rwx : refer to permission for
file owner (u).
>> second rwx : refer to permission
for group from file owner(g).
>> third rwx : refer to permission for other users (o).
>> r = 4 / w=2 /x=1 sum of all permission = 7 (this mean take all per)
./file-name => to execute command in file.
chmod +x file-name(x) => to add the ability to execute the file in all
directions of permission.
chmod +r file-name(x) => to add the ability to read the file in all directions
of permission.
chmod +w file-name(x) => to add the ability to write in the file in all
directions of permission.
chmod -r file-name(x) => to prevent the ability to read the file in all
directions of permission.
chmod u-r file-name(x) => to prevent the ability to read the file from user.
chmod g-r file-name(x) => to prevent the ability to read the file from group
owner.
chmod o-r file-name(x) => to prevent the ability to read the file from other
users.
chmod 777 file-name(x) => to add all
abilities (read-write-execute) in all
directions of permission.
touch .file-name(x): to make new
hidden file with name x.
Commands of compression and Decompression :-
gzip file.name (x) => to compress only file with the name (x).
gunzip compressed file.name (x).gz => to decompress the compressed file
with the name (x).
zcat file-name(x) => to show data in compressed file with name(x).
du -h folder(x) => to show the size of folder(x).
tar -zcvf compressed-file-name.tgz folder(x) : to compress the folder(x)
into compressed-file name with extension (tgz) for decreasing the size of
folder.
tar -zxvf compressed-file-name.tgz folder(x) : to decompress the folder(x)
from compressed file with extension (tgz).
Root Mode
>> is a special mode that help to make some operations that
need a high permission to do it.
>> To make any command in root mode: you must write ( sudo ) before any
command expect command of ( ls ).
>> sudo :- execute a command as another user.
>> “/” :- is the symbol used to represent the top-level directory.
Commands of root mode :-
cd => to return to user mode.
cd / => to enter to root mode.
sudo command => to execute the command in root mode then enter the
password of user to perform this command.
sudo adduser name-of-user => to add a user or group to the system.
sudo chown name-of-user file/folder-name => change ownership of a file
to access by new user.
sudo chown name-of-user:name-of-user file/folder-name => change file
owner and group to access by new user.
cat /etc/passwd => concatenate the file passwd from folder etc and print all
`operation done and the name of user that do it.