linux shell or terminal is a program that receives commands from the user and gives
it to the os to process. and it shows the output . linux's shell is its main
part ,linux has a CLI (command line interface).in this tutorial , we are going to
over the basic commands that we use in the shell of linux.
----------------------------------------------------------------------------
there are 3 types of user account types :
1- regular
2-root
3-service account
----------------------------------------------------------------------------
commands of linux
1- uptime ---> current system time and the duration for which system has been
running and number of users logged in and system load average
2- uptime -p --> show uptime in pretty format
3- uptime -h --> display this help and exit
4- uptime -s --> system up since
5- uptime -V -->output version information and exit
----------------------------------------------------------------------------
1- w command --> will display users currently logged in and their process along
with showing load averages , login name , tty name , remote host login time , idle
time , jcpu ,pcpu , command and processes
2- w -h --> displays no head entries
3- w -s -->without jcpu and pcpu
4- w -f -->removes from the field
5- w -V -->(upper letter )- shows versions
-----------------------------------------------------------------------------------
-
1- users -->command displays currently logged in users - this command doesn't have
other parameters other than help and version
-----------------------------------------------------------------------------------
-
1- who --> command simply returns the user name , date ,time and host information ,
who command is similar to w command unlike the w command who doesn't print what
users are doing
2- who -b -->displays last system reboot date and time
3- who -r -->shows current runlet
3- who -a -->displays all information cumulatively
-----------------------------------------------------------------------------------
-
1- whoami -->command is used to print the currently logged in username into your
linux system , if you are logged in as a root using sudo command whoami commant
return root as the current user
-----------------------------------------------------------------------------------
-
1- uname -a -->display linux system information
-----------------------------------------------------------------------------------
-
1- date --> show the current data and time
2- date -u --> displays the time in GMT
3 date -date "ago"--> displaying past dates
4- date -date --> date and time of next dates
-----------------------------------------------------------------------------------
-
1- cal --> show this month calendar
2- cal -y --> shows the calendar of the complete current year
3- cal 08 2000 --> shows calendar of selected month and year
-----------------------------------------------------------------------------------
-
1- ls -a -->list all files including hidden file starting with '.'
2- ls --color --> colored list
3- ls -d --> list directories whit '/'
4- ls -f --> add one char of */=>@ to enteries
5- ls -i --> list file 's inode index number
6- ls -l --> list with permissions
7- ls -la --> list long format including hidden files
8- ls -lh --> list long format with readable file size
9- ls -ls --> list with long format with file size
10- ls -r --> list in reverse order
11- ls -s --> list file size
12- ls -S --> sort by file size
13- ls -t --> sort by time &date
14- ls -x --> sort by extension name
15- ls / --> list root directory
16- ls .. --> list parent directory
17- ls * -->list subdirectories
18- ls -R -->recursive directory tree list
19-ls *.txt --> list only text files with wildcard
20- ls -d */ --> list directories only
21-ls -d $PWD/* --> list files and directories with full path
-----------------------------------------------------------------------------------
-
1- cat file name --> used to display the content of text files
2- cat file1 file2 file3 >file --> used to combine several files to one file
-----------------------------------------------------------------------------------
-
1- cp [option ] source destination --> copy the source in the destination
2- cp -i --> prompt for confirmation when copying a file
-----------------------------------------------------------------------------------
-
1- mv source destination --> move file or folder from source to destination
2- mv * .source destination --> move all folders in source to the destination
-----------------------------------------------------------------------------------
-
1- gzip [options] [filenames] --> is used to compresses files
2- gunzip --> is used to compress or expand files
3- zcat --> is used to look at a gzipped file without actually having to gunzip it
(same as gunzip -c)
-----------------------------------------------------------------------------------
-1- history --> lists commands you have done recently
2- history -c --> remove all history commands
-----------------------------------------------------------------------------------
-
1- df --> see how much free disk space
2- df -m --> show available space in megabytes
-----------------------------------------------------------------------------------
-
1- du --> estimate disk usage of directory in bytes
-----------------------------------------------------------------------------------
-
1- tail [option] file --> is used to output the last part of files
2- sed 10q file --> print the first 10 lines of a file
-----------------------------------------------------------------------------------
-
1-sudo --> if you want any command to be done with administrative or root
-----------------------------------------------------------------------------------
-
1- nano file --> to create file and write in the file
-----------------------------------------------------------------------------------
-
1- sudo useradd username --> to add new user
2- cat /etc/passwd --> to show all users
3- sudo addgroup groupname --> to create new group
-----------------------------------------------------------------------------------
-
1- chown --> command is used to change the file owner or group
2- chgrp--> is used to change the group ownership of a file or directory
3- sudo chown user:group filename --> to change each user and group in one line
-----------------------------------------------------------------------------------
-
chmod --> used to reset permissions of the file or the folder