Daily life Linux Commands Last Updated : 23 Jul, 2025 Suggest changes Share Like Article Like Report Clear the Terminal : In our daily life, we use to work on Terminal if we are using LINUX. Continuous working on terminal makes the terminal screen full of commands and for removing them and making our screen totally free of character, we often use clear command. Key combination ‘Ctrl+l‘ has the same effect as ‘clear‘ command. So from next time use ctrl+l to clear your Linux Command Line Interface. Note: Since ctrl+l is a key combination, so we can not use it inside a script. If we need to clear screen inside a shell script, we just have to call command ‘clear’. Run command and get back to the directory, together: This is also an amazing hack not known to many people. We may run command no matter what it is and then return back to the current directory. For this, all we need to do is to run the command in parentheses i.e., in between ( and ). For Example : Input : cd /home/shivam/Downloads/ && ls -l Output : -rw-r----- 1 shivam shivam 54272 May 3 18:37 text1.txt -rw-r----- 1 shivam shivam 54272 May 3 18:37 text2.txt -rw-r----- 1 shivam shivam 54272 May 3 18:37 text3.txt Explanation : In the above command it first changed the current directory to Downloads and then list the content of that directory before returning back to the current directory. Shortcut to Directories: You can create a shortcut to frequently accessed directories by adding them to the CDPATH environment variable. So, say If you frequently access "/var/www/html/". Instead of typing "cd /var/www/html", you can add /var/www/ to CDPATH and then you have to type "cd html" only. shivam:~> export CDPATH=$CDPATH:/var/www/ shivam:~> cd html shivam:~:html> Replacing words or characters: If you are working with any text file then to replace every instance of any word say "version" with "story" in myfile.txt, you can use sed command as: # sed 's/version/story/g' myfile.txt Additionally, if you want to ignore character case then you may use gi instead of g as: # sed 's/version/story/gi' myfile.txt Here are some useful shortcuts which you may use while working on terminal: Cursor Movement Control: Ctrl-a: Move cursor to the start of a line Ctrl-e: Move cursor to the end of a line Ctrl-Left/Right: Navigate word by word (may not work in all terminals)Modify Text: Ctrl-w: Delete the whole word to the left of the cursor Ctrl-k: Erase to end of line Ctrl-u: Erase to beginning of line Run top in batch mode: 'top' is a handy utility for monitoring the utilization of your system. It is invoked from the command line and it works by displaying lots of useful information, including CPU and memory usage, the number of running processes, load, the top resource hitters, and other useful bits. By default, top refreshes its report every 3 seconds. Mostly we run 'top' inside the terminal, look on the statistics for a few seconds and then graciously quit and continue our work. Better yet, if we wants to run such a utility only for a given period of time, without any user interaction: There are many possible answers: You could schedule a job via cron. You could run a shell script that runs ps every X seconds Instead of going wild about trying to patch a script, there's a much, much simpler solution: top -b -d 10 -n 3 >> top-file We have top running in batch mode (-b). It's going to refresh every 10 seconds, as specified by the delay (-d) flag, for a total count of 3 iterations (-n). The output will be sent to a file.Here is a screenshots of outut: Duplicate pipe content: 'tee' is a very useful utility that duplicates pipe content. Now, what makes tee really useful is that it can append data to existing files, making it ideal for writing periodic log information to multiple files at once. ps | tee file1 file2 file3 We're sending the output of the ps command to three different files! Or as many as we want. As you can see in the screenshots below, all three files were created at the same time and they all contain the same data. export: The 'export' command is one of the bash shell BUILTINS commands.It has three available command options. In general, it marks an environment variable to be exported with any newly forked child processes and thus it allows a child process to inherit all marked variables. Frequently Used Options with 'export' -p : List of all names that are exported in the current shell -n: Remove names from export list -f : Names are exported as functions Example : command without 'export': $ a = geeksforgeeks.org $ echo $a geeksforgeeks.org $ bash $ echo $a From the above we can see that any new child process forked from a parent process by default does not inherit parent's variables. This is where the export command comes handy. $ a = geeksforgeeks.org $ echo $a geeksforgeeks.org $ export a $ bash $ echo $a geeksforgeeks.org $ On line 3, we now have used the export command to make the variable "a" to be exported when a new child process is created. As a result the variable "a" still contains the string "geeksforgeeks.org" even after a new bash shell was created. basename - Strips directory and suffix from filenames. basename prints NAME with any leading directory components removed. If Suffix is specified, it will also remove a trailing SUFFIX. For example: To get the name of the file present in test folder $ basename test/gfg.txt gfg.txt grep: grep searches files for a given character string or pattern and can replace the string with another. This is one method of searching for files within Linux. grep [option(s)] pattern [file(s)] Search number of files: grep can search any number of files simultaneously. Thus, for example, the following would search the three files file1, file2 and file3 for any line that contains the string GfG grep GfG file1 file2 file3 Search text in all files: To search all text files in the current directory (i.e., the directory in which the user is currently working), if there is a phrase "Linux is" grep 'Linux is' * There are lot of more options which can be tried using grep command. K kartik Article Tags : Linux-Unix linux-command Explore Linux/Unix Tutorial 10 min read Getting Started with LinuxWhat is Linux Operating System 10 min read LINUX Full Form - Lovable Intellect Not Using XP 2 min read Difference between Linux and Windows 7 min read What are Linux Distributions ? 8 min read Difference between Unix and Linux 5 min read Installation with LinuxHow to Install Arch Linux in VirtualBox? 7 min read Fedora Linux Operating System 12 min read How to install Ubuntu on VirtualBox? 6 min read How to Install Linux Mint? 3 min read How to Install Kali Linux on Windows? 2 min read How to Install Linux on Windows PowerShell Subsystem? 2 min read How to Find openSUSE Linux Version? 2 min read How to Install CentOS 2 min read Linux CommandsLinux Commands 15+ min read Essential Unix Commands 7 min read How to Find a File in Linux | Find Command 9 min read Linux File SystemLinux File System 12 min read Linux File Hierarchy Structure 6 min read Linux Directory Structure 6 min read Linux KernelLinux Kernel 4 min read Kernel in Operating System 3 min read How Linux Kernel Boots? 11 min read Difference between Operating System and Kernel 3 min read Linux Kernel Module Programming: Hello World Program 7 min read Linux Loadable Kernel Module 7 min read Loadable Kernel Module - Linux Device Driver Development 4 min read Linux Networking ToolsNetwork configuration and troubleshooting commands in Linux 5 min read How to configure network interfaces in CentOS? 5 min read Command-Line Tools and Utilities For Network Management in Linux 8 min read Linux - Network Monitoring Tools 4 min read Linux ProcessProcesses in Linux/Unix 6 min read How to Manage Process in Linux 4 min read Getting System and Process Information Using C Programming and Shell in Linux 2 min read Process states and Transitions in a UNIX Process 4 min read Linux FirewallLINUX Firewall 7 min read iptables command in Linux with Examples 7 min read How to Configure your Linux Firewall - 3 Methods 12 min read Shell Scripting & Bash ScriptingIntroduction to Linux Shell and Shell Scripting 8 min read What is Terminal, Console, Shell and Kernel? 5 min read How to Create a Shell Script in linux 7 min read Shell Scripting - Different types of Variables 4 min read Bash Scripting - Introduction to Bash and Bash Scripting 12 min read Bash Script - Define Bash Variables and its types 12 min read Shell Scripting - Shell Variables 6 min read Bash Script - Difference between Bash Script and Shell Script 4 min read Shell Scripting - Difference between Korn Shell and Bash shell 3 min read Shell Scripting - Interactive and Non-Interactive Shell 3 min read Shell Script to Show the Difference Between echo â$SHELLâ and echo â$SHELLâ 4 min read My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like