Posted: . At: 11:16 AM. This was 7 years ago. Post ID: 10639
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

Some very important Linux tips for new and advanced users.

  1. Some obscure Linux tips for the advanced Linux user
  2. Download a new kernel for your Ubuntu Linux machine

Some obscure Linux tips for the advanced Linux user

The magic SysRQ key combination is used to reset the Linux system if nothing else will work. To use this key combination, press: Alt+SysRQ then tap these keys in order: R, S, E, I, U, B. This will perform a safe re-boot of your Linux system assuming the Magic SysRQ keys are enabled in your Linux kernel.

The dstat utility for Linux replaces vmstat and iostat and provides a lot of information about your system with live statistics of CPU, network or disk usage.

Type sudo apt install dstat to install this utility.

localhost% dstat -cglmnpry
--total-cpu-usage-- ---paging-- ---load-avg--- ------memory-usage----- -net/total- ---procs--- --io/total- ---system--
usr sys idl wai stl|  in   out | 1m   5m  15m | used  free  buff  cach| recv  send|run blk new| read  writ| int   csw 
  7   1  82  10   0|   0     0 |0.53 0.43 0.50|2358M 7535M  287M 1489M|   0     0 |  0   0 1.8|60.4  7.27 |2603  6235 
  3   1  96   0   0|   0     0 |0.53 0.43 0.50|2359M 7534M  287M 1489M|   0     0 |  0   0   0|   0     0 |1823  5231 
  4   1  94   1   0|   0     0 |0.53 0.43 0.50|2359M 7534M  287M 1489M|  64B   64B|  0   0 1.0|   0  5.00 |1805  4915 
  3   1  96   0   0|   0     0 |0.53 0.43 0.50|2359M 7534M  287M 1489M|   0     0 |  0   0   0|   0  4.00 |1849  5036 
  4   1  95   0   0|   0     0 |0.53 0.43 0.50|2360M 7534M  287M 1489M| 303B 2018B|  0   0   0|   0     0 |1805  5029 
  4   1  95   0   0|   0     0 |0.49 0.42 0.49|2359M 7534M  287M 1489M| 847B  305B|  0   0   0|   0     0 |1818  5171 
  4   1  95   0   0|   0     0 |0.49 0.42 0.49|2360M 7534M  287M 1489M|   0     0 |  0   0   0|   0     0 |1816  5150 
  3   1  96   0   0|   0     0 |0.49 0.42 0.49|2360M 7534M  287M 1489M|   0     0 |  0   0   0|   0     0 |1764  4974 
  5   1  94   1   0|   0     0 |0.49 0.42 0.49|2360M 7534M  287M 1489M|   0     0 |  0   0   0|   0  27.0 |1929  5460 
  4   1  95   0   0|   0     0 |0.49 0.42 0.49|2360M 7534M  287M 1489M|  70B   70B|  0   0   0|   0     0 |1885  5660 
  4   1  95   0   0|   0     0 |0.53 0.43 0.50|2360M 7534M  287M 1489M|  70B   70B|  0   0   0|   0     0 |1838  5421 
  4   1  95   0   0|   0     0 |0.53 0.43 0.50|2360M 7533M  287M 1489M|   0     0 |  0   0   0|   0     0 |1877  5463 
  5   1  95   0   0|   0     0 |0.53 0.43 0.50|2360M 7533M  287M 1489M|   0     0 |  0   0   0|   0     0 |1857  5125 
  4   1  96   0   0|   0     0 |0.53 0.43 0.50|2360M 7533M  287M 1489M|   0     0 |1.0   0   0|   0     0 |1857  5391 
  4   1  95   0   0|   0     0 |0.53 0.43 0.50|2360M 7533M  287M 1489M|   0     0 |4.0   0   0|   0     0 |1797  5206 
  4   1  95   0   0|   0     0 |0.57 0.44 0.50|2360M 7533M  287M 1489M|  64B   64B|  0   0   0|   0     0 |1825  5107 
  4   1  95   1   0|   0     0 |0.57 0.44 0.50|2360M 7533M  287M 1489M|   0     0 |  0   0   0|   0  3.00 |1837  5276 
  3   1  96   0   0|   0     0 |0.57 0.44 0.50|2361M 7533M  287M 1489M|   0     0 |  0   0   0|   0     0 |1817  5351 
  4   1  95   0   0|   0     0 |0.57 0.44 0.50|2361M 7533M  287M 1489M|   0     0 |  0   0   0|   0  1.00 |1789  5010 
  4   1  95   0   0|   0     0 |0.57 0.44 0.50|2361M 7533M  287M 1489M| 326B 2081B|  0   0   0|   0     0 |1860  5399 
  4   1  95   0   0|   0     0 |0.60 0.45 0.50|2361M 7532M  287M 1489M| 961B  392B|  0   0   0|   0     0 |1904  5375 
  4   1  95   0   0|   0     0 |0.60 0.45 0.50|2361M 7532M  287M 1489M|  64B    0 |  0   0   0|   0     0 |1861  5391 
  4   1  95   0   0|   0     0 |0.60 0.45 0.50|2361M 7532M  287M 1489M|   0     0 |  0   0   0|   0     0 |1798  5395 
  4   1  95   1   0|   0     0 |0.60 0.45 0.50|2361M 7532M  287M 1489M|   0     0 |  0   0   0|   0  4.00 |1810  5123

To count lines of code in a C project file, install the cloc utility and execute it as as shown below.

sudo apt install cloc

Then count the lines of code in a C file.

localhost% cloc ip.c 
       1 text file.
       1 unique file.                              
       0 files ignored.
 
github.com/AlDanial/cloc v 1.70  T=0.03 s (32.7 files/s, 3400.8 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                                1             19             16             69
-------------------------------------------------------------------------------

The atop utility is another good tool for Linux, this shows comprehensive information about your Linux machine.

Type this command to install this.

sudo apt install atop

Then run it to get very comprehensive information about a machine. Very cool.

The atop utility showing comprehensive information about my system.
The atop utility showing comprehensive information about my system.

The jnettop utility is a good way to monitor the network traffic on your Linux machine.

Use this command to install it.

[root@localhost ~]# dnf install jnettop
The jnettop command monitoring network packets on a Fedora 25 machine.
The jnettop command monitoring network packets on a Fedora 25 machine.

The mtr command is a nice alternative to traceroute. This is used in this way.

[root@localhost ~]# mtr 8.8.8.8

Gives a nice output, showing the paths taken by the network packets.

If you wish to edit the last executed bash command in VI and then edit it, then use the fc command. This will open your last executed command in VI, you can edit it and then exit VI and the command will be executed. This could be very useful for a very long one-liner.

Use this command to list all applications using the Internet. The ss command is used to list socket statistics.

localhost% ss -p | grep http
tcp    ESTAB      0      0      192.168.100.2:43030                104.24.8.94:https                 users:(("firefox",pid=2235,fd=106))
tcp    ESTAB      0      0      192.168.100.2:52418                157.240.8.18:https                 users:(("firefox",pid=2235,fd=113))
tcp    ESTAB      0      0      192.168.100.2:60420                52.84.207.247:https                 users:(("firefox",pid=2235,fd=112))
tcp    ESTAB      0      0      192.168.100.2:47754                122.149.3.18:https                 users:(("firefox",pid=2235,fd=88))
tcp    ESTAB      0      0      192.168.100.2:46610                104.19.192.102:https                 users:(("firefox",pid=2235,fd=107))
tcp    ESTAB      0      0      192.168.100.2:41736                157.240.8.23:https                 users:(("firefox",pid=2235,fd=111))
tcp    ESTAB      0      0      192.168.100.2:51504                34.204.80.1:https                 users:(("firefox",pid=2235,fd=36))
tcp    ESTAB      0      0      192.168.100.2:60416                52.84.207.247:https                 users:(("firefox",pid=2235,fd=109))
tcp    ESTAB      0      0      192.168.100.2:47650                216.58.220.110:https                 users:(("firefox",pid=2235,fd=103))
tcp    ESTAB      0      0      192.168.100.2:44382                35.160.19.195:https                 users:(("firefox",pid=2235,fd=81))
tcp    ESTAB      0      0      192.168.100.2:34176                157.240.8.35:https                 users:(("firefox",pid=2235,fd=108))
tcp    ESTAB      0      0      192.168.100.2:48774                172.217.25.174:https                 users:(("firefox",pid=2235,fd=51))

Very useful indeed.

Another way to cat a file from the command line.

localhost% dd if=pikachu.ascii bs=1
                       ▀▄     
                      ▀▀▀▀    
                      ▀▀▀▀▀   
                     ▀▀▀▀▀▀   
       ▄▄▄▄▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  
 ▄▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄ 
 ▄▀▀▀▀▀ ▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
▀▀▀▀▀▀▀▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ 
   ▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ 
  ▀▀▀▀▀▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ 
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ 
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  
      ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   
        ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   
         ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄   
         ▀▀▀▀▀    ▀▀▀▀▀▀▀▀▀   
14990+0 records in
14990+0 records out
14990 bytes (15 kB, 15 KiB) copied, 0.0128079 s, 1.2 MB/s

The dd command can be used to cat files, just use it this way and it works very well.

List your most popular Linux commands in your bash history.

ubuntu ~ $ cat .bash_history | cut -d ' ' -f1 | sort | uniq -c | sort -nr | head -20
    413 sudo
    170 ls
    108 cd
    101 cat
     83 su
     79 ps
     73 mc
     54 man
     47 ifconfig
     46 echo
     35 john
     26 vim
     25 sipcalc
     24 nmap
     24 ip
     17 grep
     16 ping
     16 gcc
     16 curl
     15 uptime

Download a new kernel for your Ubuntu Linux machine

This website hosts kernel packages for the Ubuntu distribution with daily builds available.

http://kernel.ubuntu.com/~kernel-ppa/mainline/.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.