Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Linux Commands AWS Linux Commands A command is an instruction given by a user telling a computer to do something, such a run a single program or a group of linked programs. Commands are generally issued by typing them in at the command line (the all-text display mode) and then pressing the ENTER key, which passes them to the shell. The first word is the command itself, which tells the shell “what” to do. The remaining words are commands options. An option controls “how” the command is to be performed. AWS Linux Commands
Linux Commands AWS Linux Commands Shell is a UNIX term for the interactive user interface with an operating system. The shell is the layer of programming that understands and executes the commands a user enters. In some systems, the shell is called a command interpreter. The term shell derives its name from the fact that it is an outer layer of an operating system. A shell is an interface between the user and the internal parts of the operating system (at the very core of which is the kernel). AWS Linux Commands
Linux Commands Shell AWS Linux Commands
Linux Commands AWS Linux Commands
Linux Commands AWS Linux Commands
Linux Commands AWS Linux Commands User Name General User’s Symbol Host Name Home Directory of the User AWS Linux Commands
Linux Commands AWS Linux Commands Super User’s Symbol Super user is also known as Root user AWS Linux Commands
Linux Commands AWS Linux Commands ls Lists the information about files and directories. Syntax ls directory-name Options ls –l (long/detailed form) ls –lh (long and human readable form) ls –a (lists all files, also hidden files) ls –t (sort by time) AWS Linux Commands
Linux Commands Symbol Meaning - File b Block Device c Special File d File symbols which lists using ls command output. Symbol Meaning - File b Block Device c Special File d Directory l Link s Socket File AWS Linux Commands
Linux Commands AWS Linux Commands cd Command use to change working directory. Syntax cd /path/directory-name Options cd - (Jump to old working directory) cd OR cd ~ (Jump to home directory of login user) cd .. (Jump to parent directory of current woking directory) cd ../.. (Same as cd.. But jump two step back) AWS Linux Commands
Linux Commands AWS Linux Commands pwd Print the name of current working directory. Syntax AWS Linux Commands
Linux Commands AWS Linux Commands mkdir To create a new directory. Syntax mkdir directory-name Options mkdir -p (to make parent directory as we have needed) AWS Linux Commands
Linux Commands AWS Linux Commands rmdir To remove empty directory. Syntax rmdir dir-name AWS Linux Commands
Linux Commands AWS Linux Commands touch To create an empty file. To update the access and modification time of existing file or directory. Syntax touch file-name touch dir-name AWS Linux Commands
Linux Commands AWS Linux Commands stat To view the status of a file or directory. Syntax stat file-name AWS Linux Commands
Linux Commands AWS Linux Commands file This command is used to determine a file’s file type. Synatx file file-name AWS Linux Commands
Linux Commands AWS Linux Commands rm To remove file or directory. Synatx rm file-name rm -r dir-name Options rm -f (to remove a file forcefully) rm -r (to remove a directory/recursively) rm -rf (to remove a directory forcefully) AWS Linux Commands
Linux Commands AWS Linux Commands mv To move file or directory from one location to an other location. Also used to rename file and directory. Syntax mv file-name /location mv old-name new-name AWS Linux Commands
Linux Commands AWS Linux Commands cat To view contents of file. Also used to create new text file. Syntax cat file-name (to view the file contents) cat > file-name (to create a text file) cat >> file-name (to append the text existing file) Ctrl+d (to save contents of the file) Options cat -n (to view contents of file with line numbers) AWS Linux Commands
Linux Commands AWS Linux Commands cp Use to copy the files and directories. Syntax cp file1 file2 cp -f file1 file2 (to copy file forcefully) cp -r dir1 dir2 (to copy directory recursively) AWS Linux Commands
Linux Commands AWS Linux Commands uname Use to show the kernel name and other information. Synatx Options uname -o (to show OS name) Uname -r (to show kernel version) Uname -v (to show kernel release) uname -n (to show hostname) AWS Linux Commands
Linux Commands AWS Linux Commands echo To print the string on the screen. Also used to create file. Syntax echo string to print echo string to save > file-name echo string to append >> file-name AWS Linux Commands
Linux Commands AWS Linux Commands which To locate the path of command or program. Syntax which command which cp AWS Linux Commands
Linux Commands AWS Linux Commands cal To display calendar. Syntax Options cal -y (to show the complete calendar) cal -m (calendar start from Monday) cal -j (to show Julian calendar) cal -3 (to show previous, current and next month calendar) AWS Linux Commands
Linux Commands AWS Linux Commands wc Print byte, word, and line counts. Syntax wc file-name Options wc -c (to count characters of file) wc -w (to count words of file) wc -l (to count lines of file) AWS Linux Commands
Linux Commands AWS Linux Commands who Print information about users who are currently logged in Syntax Options who -H (out put with heading) who -b (to show boot time) who -r (to show current runlevel) AWS Linux Commands
Linux Commands AWS Linux Commands whoami Show current logged on user on terminal. Syntax AWS Linux Commands
Linux Commands AWS Linux Commands more To display the contents of a file from top to bottom. Syntax more file-name Navigation Keys Enter key Use to page down line by line Space key Use to page down page by page AWS Linux Commands
Linux Commands AWS Linux Commands less To display the contents of the file. We can navigate the page up and down line by line and page by page Syntax less file-name AWS Linux Commands
Linux Commands AWS Linux Commands head To display the first part of the file. Syntax head file-name Options head -n (to show n (number) lines of file) AWS Linux Commands
Linux Commands AWS Linux Commands tail To display the last part of the file. Syntax tail file-name Options tail -n (to show n (number) lines of file) tail -f (to follow the file updating) AWS Linux Commands
Linux Commands AWS Linux Commands | Pipe line. Redirect the output of one command into another command. Syntax commad1 | command2 ls -l | wc -l ls -l /etc | less AWS Linux Commands
Linux Commands AWS Linux Commands history To view the commands line history. Syntax history file-name Options history -c (clear the history) history -w file-name (to save the history in text file) AWS Linux Commands
Linux Commands AWS Linux Commands tac To view the contents of file in reverse order. Syntax tac file-name tac > file-name tac >> file-name AWS Linux Commands
Linux Commands AWS Linux Commands grep To matching pattern. To search the given pattern in file Syntax grep pattern file-name grep pattern file-name1 file-name2 cat file-name | grep pattern Options grep -i (To ignore case sensitivity) grep --color (To high light pattern) AWS Linux Commands
Linux Commands AWS Linux Commands tr To translate the contents of file from lower case to upper case and vise versa. Syntax tr 'a-z' 'A-Z' < file-name cat file-name | tr 'a-z' 'A-Z' cat file-name | tr 'a-z' 'A-Z' > new-file AWS Linux Commands
Linux Commands AWS Linux Commands hostname To view the host/machine name. To change the hostname of your machine. Syntax AWS Linux Commands
Linux Commands AWS Linux Commands ps To view the current running process. ps is the shortage for Process Status. The command should be used to display the currently running processes on Unix/Linux systems ps aux To view the all running system processes. ps -u user-name To view the current running process of given user. AWS Linux Commands
Linux Commands AWS Linux Commands kill Terminate a process. Kill command in Linux is normally used to kill a suspended or hanged process. kill -9 is used to forcefully terminate a process in Linux. Syntax kill -9 process-id AWS Linux Commands
Linux Commands AWS Linux Commands find To search/find the file or directory in current or given directory . Syntax find /path -name file-name (To find a particular file with in current/given directory as well as in its subdirectories) AWS Linux Commands
Linux Commands AWS Linux Commands locate To search/find the location of file-name containing the matching pattern. Syntax locate file-name Options locate -c (to count the given file) locate -I (to search with limit) locate -b (to search file base name) AWS Linux Commands
Linux Commands AWS Linux Commands free To view the memory status. Syntax Options free -l (show memory with detail) free -m (show memory statistics in MBs) free -g (show memory statistics in GBs) AWS Linux Commands
Linux Commands AWS Linux Commands du To view the disk used space of any file/directory. Syntax du directory-name Options du -c (show the grand total) du -h (human readable form) du -s (show only a total size ) AWS Linux Commands
Linux Commands AWS Linux Commands df To view the disk free space. Syntax df directory-name Options df -h (show detail in human readable format) AWS Linux Commands
Linux Commands AWS Linux Commands su To switch an other user account Syntax su user-name Options su - user-name AWS Linux Commands
Linux Commands AWS Linux Commands date To display and change the date and time. Syntax Options date -s “MM/DD/YYYY hh:mm:ss” date -s “DD month YYYY hh:mm:ss” date -s “YYYY-MM-DD hh:mm:ss” date -s “YYYYMMDD hh:mm:ss” AWS Linux Commands
Linux Commands AWS Linux Commands Date format date +%T or +%X (Time) date +%a or +%A (Day) date +%D or +%F or +%x (Date) date +%b or +%B or +%m (Month) date +%G (Year) AWS Linux Commands
Linux Commands AWS Linux Commands & To set as a background job. Ctrl+z Syntax Service-name & AWS Linux Commands
Linux Commands AWS Linux Commands bg jobs To view the all background running jobs. “bg” show the total jobs. “jobs” show the jobs in sequence. Syntax AWS Linux Commands
Linux Commands AWS Linux Commands fg To set a background job as a foreground job. Syntax fg job-num AWS Linux Commands
Linux Commands AWS Linux Commands Redirectors Used to redirect data or contents to given file or new file. Syntax command > file-name command >> file-name Options > (create new file. over write contents if exist a file) >> (Append contents in existing file) AWS Linux Commands
Linux Commands AWS Linux Commands man A command use to view manual or help of linux commands. Syntax man command man cp q (press “q” key to exit from manual) AWS Linux Commands
Linux Commands AWS Linux Commands To re-start the system. halt To shut down the system. poweroff reboot To re-start the system. AWS Linux Commands
Questions & Answers Blog VaporVM 190 Route 27, L2, Edison, NJ08820 OUR EMAIL OUR WEBSITE aws@vaporvm.com http://\www.vaporvm.com http://www.vaporvm.com/us/category/training-blog/ HANDS ON TRAINING