The most important Linux commands you need daily

Use this guide to most important Linux commands, Utilities, and tools for beginners, enterprise administrators, and managers.

Directory Operations:

CommandDescription
pwdShow current directory
cd dirChange to directory dir
mkdir dirCreate a new directory dir
rmdir dirDelete directory dir
ls dirList Contents directory dir

Example:

Special Directories:

CommandDescription
.Current Directory
..Up a Directory
~Home Directory
/Root Directory
Previous Directory

Example:

ls Options:

Syntax:

CommandDescription
-aAll inc. hidden file
-lLong Format
-iList file’s inode index number
-tSort by time & date
-dList directories  with ‘ */’ [eg1. ls -d */ ][eg2. ls -d $PWD/* ]
-sList file size
-SSort by time
-rReverse order
-RRecursive
-XSort by extension name

Example:

File Operations:

CommandDescriptions
touch fileCreate a new file
cp file1 file2Copy file1 to file2
mv file1 file2Move file1 to file2
rm fileDelete a file
cat fileDisplay content of a file
cat file1 file2Cancatenate files
less fileDisplay file (paginated), q to quit
head fileShow first 10 lines
tail fileShow last 10 lines [-n N →N lines; -f → Continuos update]

File Searching:

CommandDescriptions
grep pattern fileSearching for a line with a pattern in a file
grep -vInverted search
grep -rRecursive search
grep -e pattern -e patternMultiple patterns
locate fileQuick search for a file
which cmdFind locations of binary
find dir -name patternFind a file with a pattern in dir

Example:

Standard IO Streams:

CommandDescriptions
stdinInput typed on the command line
stdoutOutput on the screen
stderrErrors output on the screen
echo stringWrite a string to stdout

Example:

Redirection:

CommandDescriptions
cmd > fileOutput of cmd to file
cmd < filefile used as input to cmd
cmd >> fileAppend output to file
cmd 2> fileWrite errors to file
cmd &> fileErrors and stdout to file

Pipe Multiple Commands

CommandDescriptions
cmd1 | cmd2Stdout of cmd1 is used as input to cmd2
cmd1 | &cmd2Stderr of cmd1 is used as input to cmd2
cmdpart1 \ cmdpart2Continue command on next line
cmd1; cmd2Execute cmd1 then cmd2

Processes:

CommandDescriptions
psShow processes of user
ps -eShow all processes
ps -fAShow all processes in detail
topShow all processes in real-time
cmd &Run command in the background
Ctrl-cStop (kill) currently active process
Ctrl-zSuspend currently active process
bgPlace suspended process in a background
fgBring background process to foreground
kill pidKill process with process id PID
Kill -9 pidKill process PID (ungraceful)

Bash Shortcuts:

CommandDescriptions
Ctrl-kCut line of text
Ctrl-yPast line of text
Ctrl-eGo to end of line
Ctrl-aGo to start of line
TABAutocomplete command/file
TAB-TABShow list of possible autocompletes
up arrowScroll previous commands
down arrowScroll previous commands
histroryList recent commands
!!Repeat the last command
!NExecute command N from history
!abc:pPrint the last command starting with abc
!abcExecute the last command starting with abc

Text file operation:

CommandDescriptions
wcLine, word and character count
sort fileSort file, line by line
uniq fileDisplay only unique lines of a file
sed ‘s/abc/def/g’ fileReplace all occurrence of abc with def, out to stdout
cut -d “ “ -f N fileDisplay field N of space delimited file
cut -d “,” -f M-N fileDisplay field M-N of a comma delimited file

Tar Command:

CommandDescriptions
-cCreates a new .tar archive file.
-xTo untar or extract a tar file
-vVerbosely show the .tar file progress.
-fFile name type of the archive file.
-zcompressed gzip archive file
-rTo add files or directories to existing tar archive file
-jTo create a highly compressed tar file
-Cuntar in a different directory
-tviewing content of archive file
-WVerify an archive file

Example:

How to create a tar.gz file

To create a tar.gz archive from a given folder you can use the following command

How to extract a tar.gz file

To extract a tar.gz compressed archive you can use the following command

How to extract specific file(s) from tar.gz

Proper file Permissions for WordPress

Three-digit permissions specified in octal

octal-three-digit-permissions

How to find recently modified files

see all files that were modified during the last 2 days

How can I monitor the progress of an import of a large .sql file?

If you’re just importing from a dump file from the CLI on *nix, e.g.

then first install pipe viewer on your OS then try something like this:

How to convert ppk file from pem file?

Make sure puttygen installed on your computer. If it is not installed, type the below command,

How to download YouTube Playlist

The program ‘youtube-dl‘ is currently not installed. You can install it by typing:

Vijayan J

Thanks for stopping by guys! I'm Vijayan and Techpulse is my beloved brainchild. Currently working as a PHP developer in a digital marketing start-up, I'm overly passionate about not just learning new things but also putting those into practice. I swear by a quote I once came across... 'What separates successful people from unsuccessful people is the former's ability to execute'. Feel free to reach out to me if you have any questions, suggestions or feedback. Hoping to see more of you here!