Posts in Category: uncategorized

Linux – Compress a whole folder in Linux (using tar)

What is tar

You may have come across the gzip and bzip2 commands which are used for compressing individual files. But if you want to compress a whole directory, then the command you need to use is tar. The tar command requires you to declare a number of options for it work, so the best way to understand how tar works is to see it in action:

Creating a tar file.

The tar command has several different modes, and to generate a tar file, you need to enable the “create” mode. Here’s how you compress a whole directory.

tar -cf {tar-filename} /path/to/dir

For the above, you can read the options “-cf” as: (c)reate a tar (f)ile with the name {tar-filename}, using the content from /path/to/dir.

If you want to do the above, but also see the


Linux – Temporarily switch to another Linux user (using su)

## How to switch users or temporarily become root

## Commands covered in this article
id            # Displays the username of the currently logged in user. It also displays what groups the user belongs to.
su        # Lets you (s)witch to another (u)ser while logged in as someone else.
sudo      # xxxxxxxxxxxxxxxxx

## Become the root user using “su”
In linux it is always recommended that you avoid logging in as the root user directly. That’s because it can cause security issues and increases the chances of damaging something. In fact, Centos will display a warning message when you attempt a direct root login.

So the best practice is that you always login as a normal user.


Give a user more priveleges using sudo

## Setting up and assign sudo priveleges

The Sudo utility lets you give a users custom privileges so that they can run commands that they are not normally allowed to run.

For example, only the root user can run the “Shutdown” command. But if you want give another user permission to run this command, then you can do this using sudo.

To configure privileges, all you have to do is edit the sudo’s config file (which is called sudoers):

/etc/sudoers

## Use visudo instead of vim.
Be careful that you don’t make any errors when editing the sudeors file. Thats becuase any errors can stop your machine from booting up. One way to avoid making errors is to use visudo to edit the sudoers file. visudo is a specialized version of vim that has been


Linux – Accessing the linux terminal

The way you access the   linux command line terminal, depends on the scenario:

Scenario 1 – Access your Linux desktop machine’s terminal

Using the gnome ui, interface, simply go to:

Useful Tip: you can create a desktop shortcut to save time.

Scenario 2 – Access a remote linux server’s   terminal from a windows desktop machine.

In most corporate workplaces, linux servers are locked away in server rooms. In these cases, you can access the server’s terminal remotely by using a software called putty. Putty creates a connection to the linux server and opens up a virtual terminal. After that you can use this terminal just as if you were access the linux server directly.

Useful Tip: In a corporate workplace, you may need to remotely connect to several remote linux machines. Then you might