Part 1 : 13 Essential Linux Commands for Your Daily Workflow
Navigation
(Use these commands to to move inside the file system and know the contents of specific path in the file system):ls
: This command lists the contents of the current directory. Use flags like-l
for detailed listings or-a
to show hidden files. Just like in windows we double click and see the contents of a folder,ls
command is the same thing.cd
: Change directories withcd
. Navigate to your home directory withcd ~
or move up a directory level withcd ..
File & Folder Creating & Deletion:
(Use these command to create a file or a folder)mkdir
: Create new directories(folder) usingmkdir
For example:mkdir folder1
will create a folder namedfolder1
in the current directory you are in.
Need a subdirectory structure? Chain commands likemkdir project/data/reports
.touch
: Create empty files withtouch
.
For example:touch file.txt
will create a file with namefile.txt
in the current directory you are in.echo
: Echo just print some text to the command line but we can use it to add some content to the file we are creating. Use theecho
&touch
commands together to create a file, but with some content in it.
For example:echo "Hello I am content!" > touch file.txt
rm
: Okay we know how to make folder and files but how to delete them?
Userm
for that. Navigate to the folder that contains the file you want to remove then userm <file_name_here>
this will delete the file name specified.Removing folder is not same though, use
-r
option withrm
.
Userm -r <folder_name>
to delete a folder and its files too.
Viewing Files:
cat
: Display the contents of a file.
For example:cat file.txt
will show all the content of this file.tail
: Want to see the last few lines of the file?
Pipe cat withtail
:cat file.txt | tail -n 5
.head
: Want to see the top few lines?
Pipe cat withhead
:cat file.txt | head -n 5
.less
: For larger files, useless
for a pager view. Navigate with arrow keys and exit withq
.
Know exactly where you are & your storage usage:
pwd
: This simple command prints the absolute path(means complete path) of your current working directory. Essential for knowing your current location in the file system.df
: Check disk usage withdf
. Identify partitions running low on space and plan your storage accordingly.
Know which processes are running in the system:
ps
: See a list of running processes withps
. Use flags like-aux
for a more detailed view including user, PID, and CPU usage.
Part 2 : Learn how to quick move the cursor in terminal & Move Between Command History
Ctrl+A: Instantly move your cursor to the absolute beginning of the line for quick edits.
Ctrl+E: Counterpart to
Ctrl+A
, this places your cursor at the line's end, perfect for appending text.Backspace/Delete: Delete characters; backspace removes the character behind the cursor, while
Delete
removes in front.Ctrl+W: Delete the entire word(just one word not everything) left of your cursor for faster corrections.
Ctrl+U/Ctrl+K: For larger deletions,
Ctrl+U
wipes everything from the left of the cursor, whileCtrl+K
clears everything from the right of the cursor.
Time Traveling Through History:
(When we write commands, they go to the history, from which we can retrieve them back)
Up/Down Arrows: These cycle through your command history, allowing you to recall and edit past commands.
!!: Execute the last command you typed again with a double bang. Need the second-to-last command? Use
!
followed by the history number (!-2
).Ctrl+R: Enter reverse search. Start typing characters, and the terminal will navigate through your history based on what you enter. Press
Ctrl+R
again to cycle through matching entries,Ctrl+O
to accept and execute the highlighted command, orCtrl+G
to exit the search.
The END
That's It, for daily use and normal usage, these are the only commands and tricks you need 80%-90% of the time. Of course i will make more blogs on advanced stuff but for daily usage this is kind of enough.
Love You Thanks!