5 Commands Every Linux Newbie Must Know – sathyasays.com
This page looks best with JavaScript enabled

5 Commands Every Linux Newbie Must Know

 ·   ·  ☕ 3 min read  ·  ✍️ Sathyajith Bhat · 👀... views

Although Linux had progressed far from being a command-line only OS to a full fledged totally GUI based one, sometimes, the command line is the best way to get something done. Here are 5 of the must-know commands. These commands can b quite useful and handy.

1: mount: Used for mounting Windows/Other partitions, just in case it isn’t automatically mounted.

Usage:

mount

here refers to the special device where your partitions are.

Rather than referring to partitions as drive letters as Windows, every partition in Linux is indicated by a special device. For eg in case if IDE(parallel ATA drives) the Primary master will be /dev/hda and the primary partition will be /dev/hda1(Windows C:) and the logical partitions will be /dev/hda5, /dev/hda6 and so on(for Windows D:, E:.. so on).

indicates to which directory you want the partition to be available as.

Please note that mount command requires root privileges, so run the command as sudo ie,

sudo mount

Eg: If you wish to mount the Windows C partition to a /windows/C the command will be,sudo mount /dev/hda1 /windows/C

For SATA drives, the “hdx” will be replaced by “sdx” ie, instead of /dev/hda1

it’ll be /dev/sda1

2: tar/bzip2/bunzip2: For extracting archives, this command is useful for extracting to directories other than the home directory, where root privileges are required

Usage:

(i) For GZipped files(.tar.gz extension)

tar xvfz

Eg: If the archive name is some-file.tar.gz, then the command will be

tar xvfz some-file.tar.gz

(ii)For Bzipped files (.tar.bz2 extension)

First, unzip the archive using

bunzip2

Then untar using the command

tar xvf

Eg: If the archive is some-file.tar.bz2 then first unzip it using

bunzip some-file.tar.bz2

You’ll get the file some-file.tar. Next untar it using

tar xvf some-file.tar

  1. rpm/dpkg - Install/Upgrade/Remove RPM/Debian Packages

Usage:

(i) Installing new packages

rpm -ivh <package-name.rpm>

dpkg -i <package-name.deb>

(ii) Upgrade existing packages

rpm -Uvh <package-name.rpm>

dpkg -i <package-name.deb>

(iii) Removing existing packages

rpm -e

dpkg -r

Note that these commands are suited for individual commands, whose dependencies are met. For complex packages, having many dependencies it’s better to use apt-get/smart.

For smart: smart install

For apt-get: apt-get install

Again these commands require root privileges, so prefix sudo before each of these commands.

  1. cat - Concatenate files and print on the standard output. Useful for viewing short text files, logs without having to open any editors

Usage:

cat /path/to/file

Eg: cat /var/log/syslog

If the text file is lengthy, pipe it via more to scroll ie

cat /path/to/file |more

Eg: cat /var/log/syslog |more

  1. dmesg - The program helps users to print out their bootup messages. Instead of copying the messages by hand, the user need only:

dmesg > boot.messages

and mail the boot.messages file to whoever can debug their problem.

dmesg |tail Outputs only the last part of dmesg, and is useful to identify any errors, which occured, say if a removable drive is inserted.

Share on

Sathyajith Bhat
WRITTEN BY
Sathyajith Bhat
Author, AWS Container Hero and DevOps Specialist

What's on this Page