A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/linux-unix/daily-life-linux-commands/ below:

Daily life Linux Commands - GeeksforGeeks

Daily life Linux Commands

Last Updated : 23 Jul, 2025

  1. 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’.
  2. 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.
  3. 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>
    
  4. Replacing words or characters:
  5. Here are some useful shortcuts which you may use while working on terminal: Cursor Movement Control:
  6. 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: 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:
  7. 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.
  8. 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' Example :
  9. 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
  10. 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)]
    There are lot of more options which can be tried using grep command.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4