Posted: . At: 7:43 PM. This was 2 years ago. Post ID: 4799
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.


Interesting and useful commands available using the BASH shell on Linux.


This is an interesting command to view your command history when you are using Bash.

┌──[jason@11000000.10101000.00000001.00000011][~]
└──╼  ╼ $ hash
hits	command
   1	/usr/bin/gethostip
   1	/usr/bin/sudo

This command is a Bash shell built-in command. If you are using the tcsh or zsh shells; this command will not be available to you. As shown below; you may also use the history command to show the last 10 commands executed by the user.

┌──[jason@11000000.10101000.00000001.00000011][~]
└──╼  ╼ $ history 10
  693  gethostip
  694  sudo apt install syslinux-utils
  695  gethostip google.com
  696  gethostip google.com | awk {"print $2"}
  697  gethostip google.com | awk '{"print $2"}'
  698  gethostip google.com | awk '{"print $1"}'
  699  gethostip google.com | awk '{print $1}'
  700  gethostip google.com | awk '{print $2}'
  701  hash
  702  history 10

This Linux command will return the IP address of a hostname. In this case the IP address of Google.

Install this command with this package.

┌──[jason@11000000.10101000.00000001.00000011][~]
└──╼  ╼ $ sudo apt install syslinux-utils
┌──[jason@11000000.10101000.00000001.00000011][~]
└──╼  ╼ $ gethostip google.com | awk '{print $2}'
172.217.24.46

You can also use the ping command to get this information but it is good to cover all the bases when discussing Linux commands.

Here is a tutorial on how to add a new user to an Ubuntu system with the command-line. http://mixeduperic.com/ubuntu/how-to-add-a-new-user-in-ubuntu-using-the-command-line.html.

Some useful tricks for the Linux command-line using the find command and backticks: http://www.securitronlinux.com/bejiitaswrath/useful-tricks-when-using-the-find-command-on-linux-and-backticks/.

How to check the status of your laptop battery and CPU temperature with the Linux command-line: http://www.securitronlinux.com/bejiitaswrath/how-to-check-laptop-battery-status-with-the-linux-command-line/.

Some miscellaneous BASH shell tricks that will amaze your friends: http://www.securitronlinux.com/bejiitaswrath/misc-bash-shell-tricks-for-the-linux-user/.


Leave a Comment

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