8 Useful Linux Commands For Beginners

1. Handling the Command Prompt in a Smart Way

Working on the command prompt is an essential task for any Linux system administrator. However many new users find it difficult to use the Bash prompt. Here are some tricks to speed up your work.

  • You can recall the last argument from the previous command to save time: “ALT” plus “.” (i.e Hold down the ALT key and press the dot).

Example: Let’s assume you created a new directory as follows:

mkdir -p /tmp/demo/software/text

Now if you would like to change the directory to /tmp/demo/software/demo type cd and press ALT plus . and see how Bash copies the argument that you gave to the previous command – in your case, it’s the path you provided to mkdir.

  • Short-cut keys for command editing :

CTRL + l : Clears the screen.
CTRL + u : Deletes the entire line.
CTRL + k : Deletes to the end of the line from the current cursor position.
CTRL + c : Cancels the command.
CTRL + z : Suspends the command.
CTRL + R : This is used to search for a command in command history.

Example : Yesterday or few hours back you have typed a very long command and need the same command again then hit CTRL + R and type the first few letters of the command.

CTRL + T : Transposes characters.

Example : Let’s assume that you wanted to type the date command and ended up typing daet. You can delete the last two characters and retype it again but you can also hit CTRL + T and you are done.

2. How to Check System Information

If you want to see system information about your computer then open terminal and type following command:

uname -a

Use manual pages for more information like which parameters are supported by uname. For example you can use -p to print the processor type. You can use man pages in following way:

man "command name"

Example : man dmidecode

3. Display the System’s SMBIOS Hardware Components

Do you want to know the entire details of each piece of hardware on your computer? Then type in the following command (Run with root permissions) :

dmidecode -t x

Replace x by :

  • 0 for BIOS.
  • 1 for system.
  • 2 for base board.
  • 3 for chassis.
  • 4 for processor.
  • 5 for memory controller.
  • 6 for memory module.
  • 7 for cache.
  • 8 for port connector.
  • 9 for system slot.
  • 10 for on board devices.
  • 11 for OEM strings.
  • 12 for system configuration options.

 

4. Limit the CPU Usage of a Process

You can use the cpulimit command to limit CPU usage of any process or application in Linux. You can limit a certain running application either by its name or by its PID.

Example : To restrict the VLC media player to go beyond a 20 per sent CPU usage limit, use the command below :

cpulimit -e vlc -l 20

We can also use the PID as follows :

cpulimit -p 5399 -l 40

To find the process name or PID then use ps -d command.

5. Text-Based Web Browsing

You may use elinks or links in text mode to browse websites from a console. elinks can not only be controlled by a keyboard but also by the mouse to an extent and is an advanced version of links.

elinks https://www.latesthackingnews.com

This will open www.latesthackingnews.com in your browser. Press the Esc key to access the menu where among other items you will find File? Exit to close the browser.

 

6. Download a Website

Here is a simple and effective way to get the files downloaded recursively from a website without actually visiting each and every link to the sub pages. This is also useful in case the pages are of type XHTML or text type—one can make them .html by use of an appropriate switch like -E. Go to the directory onto which you wish to download all the content from site and use the following command:

wget -r -p -k -E

Where :
-r is for recursive download of pages.
-p is for linking pages locally so that users can browse them easily once the download is completed.
-k is to create the directory structure.
-E is to create .html extensions to the type XHTML or text files.

7. Make Your Linux Box Speak

Ubuntu and many other distros have an inbuilt speech synthesiser called espeak. Use the following command in the terminal :

espeak Linux

Did you hear your Linux box report “linux”?
If you to hear a line then add a line in quotes as

"I'm new in Linux World"

8. Play Songs From the Command Line

You can play any song file from the command line without using any player but a utility called SOX. SOX is available in your distro’s repository. You can install it in a Debian-based system (Ubuntu) as follows :

sudo apt-get install sox

To play a song from the command line then type in the following command :

play song.mp3

where song.mp3 is the path to your MP3 file. To stop playback, hit Ctrl+C. If your song’s file name contains spaces, specify the file name within double quotes.

Example :

play "song 2.mp3"

When playing audio files you can even specify more than one input file as follows :

play "song 2.mp3" "song 3.mp3" "song 5.mp3"

 

Related posts

How to Improve Your Cyber Resilience by Strengthening User Privileges

The Dark Side of Viral Content: How Negative Reviews Can Snowball

Testing Gaming Monetization: Walking the Line Between Profit and Player Experience