Useful Basic Terminal Commands On Linux Mint 11

Want to support HowtoForge? Become a subscriber!
 
Submitted by CSch (Contact Author) (Forums) on Fri, 2011-08-19 10:09. :: Linux | Ubuntu

Useful Basic Terminal Commands On Linux Mint 11

Version 1.0
Author: Christian Schmalfeld <c [dot] schmalfeld [at]  projektfarm[dot] de>
Last edited 08/10/2011

This tutorial is supposed to show useful terminal commands to people who are new to Linux.

 

1 Preliminary Note

Terminal commands are powerful tools if they are used correctly, but can cause great damage if you are not completely aware of what you are doing. Before using commands that are new to you, look up the manual page and make sure you have your files saved and backed up.

This tutorial comes without guarantee of any kind.

 

2 Root User

On Linux Mint there is only one user with administrative rights which is the so called root user. However every system user can log him- or herself in as root to execute commands that need administrative rights to be run. I am going to show some of them in this tutorial, so what you need to do first is to log yourself in as root. Open Terminal and enter

su

You will then be asked for your password. Type it in (the letters are invisible) and hit Enter. When logged in to root, the font color of the command line will change from green to red. You will need to be extremely cautious performing commands in this mode since you have no restrictions set by the system. Make sure you know exactly what you are doing and have backups of your files made. To quit root status, just type in

exit

Instead of keeping root active the whole session, you can also use it for single actions only by placing sudo in front of the command, e.g. like this:

sudo shutdown -r 16:00

You will also once be asked to type in your password using this method.

 

3 Software Management

Instead of using package or software manager to manage your software, as always, you can do that by using Terminal. To do that you must be logged in as root user, accomlish that by using the commands from the previous step. I am going to show you how to install and uninstall software by the example of the Stellarium app. After you have logged in to root, use the apt-get command to install the app:

apt-get install stellarium

If you prefer not to be logged in as root, just put a sudo in front of the command:

sudo apt-get install stellarium

Type in your password to perform the command. After you are done with the app, uninstall it by replacing the install option within the command with remove.

apt-get remove stellarium

or

sudo apt-get remove stellarium

The apt-get command has a lot more options to choose from, which I will not explain here. For more information just open its manual page. To see how, see the end of the tutorial.

 

4 Useful Process Commands

Former Microsoft Windows users might miss the task-manager structure in Linux, in case any application just won't continue working or some other fatal error appears, but for that case Linux Mint has its own terminal commands. To print a snapshot of running processes, enter

ps -u [username]

and replace [username] with the name of the user you want a snapshot of the processes of. If you want a dynamic view of running processes, use the top command instead:

top

When using one of the above commands to view the running processes, you should have noticed the number in the first column, titled PID. This is the ID you need when you want to remove one of those processes. Should one them stop working due to misfunction or anything else, you may want to force close the process. The command you use for that is called kill. The most common uses are just the command followed by the PID (replace [PID] with a given four-digit number):

kill [PID]

or place a 9 in between kill and the PID parameter to force kill a process. Be careful using this option though since killing important system processes might cause it to crash.

kill 9 [PID]

Please notice that processes do not have the same PID everytime they are run. Always doublecheck if you got the right PID before you actually kill or even force kill a process.

Another useful command is time. Followed by another command, it shows you how much time the command the follows actually needs to be run.

time [command]

For example:

time sudo apt-get install stellarium

To shut down or reboot your system, there is the shutdown command. You can just perform instant shutdowns with it or set a specific time in multiple formats for when to do so. This can be used as sort of a time controller for your computer to automatically power off when you want it to.

shutdown [hh:mm] [message]

[hh:mm] is one of the possible formats to describe a time. View the manual page for more. You can enter a message instead of [message] which will then be shown shortly before shutdown. If you want a reboot after the shutdown, just put a -r option between shutdown and time.

shutdown -r 16:00 Going home after reboot, yay!


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Mon, 2011-08-22 23:07.

Why is this article titled "Useful Basic Terminal Commands on Mint 11" when the commands are pretty much universal default in most distributions?  Though not in Red Had distros, you will find "apt" in Debian based distros.  "locate" is found in pretty much all distributions by default except for Gentoo, where it can be emerged through portage.

Take away the title and it is a good article.

Submitted by Anonymous (not registered) on Sat, 2011-08-20 12:14.

The su command should be avoided (root password), instead use sudo -i (root use with the user password) this opens a new shell as pseudo-root user to do more than one thing as being root  and an exit or CTRL+D brings you back to your own user shell. Linux is a multi-user system and in my case not all of my computer users are a member of the sudo group.

Submitted by kurtdriver (not registered) on Tue, 2011-08-23 01:05.
Su has advantages over Sudo in many situations. It's good for when you have just one root level program to run and it doesn't leave a rootshell open, with it's attendant risks of forgetting who you are and running risky programs as root.