Karla News

Beginners Guide to Basic Commands for the Linux Terminal

So you’re thinking of picking up a Linux distro and trying it out? Great idea! But do you know how to use the Linux terminal?

Of course all Linux distros these days come with a fancy graphic user interface. In some ways, they’re almost identical to Windows. Underneath the hood, though, Linux is still a text driven operating system – and you’ll run into many of the same basic commands that people were using fifteen years ago. This can be a nightmare for a true beginner.

After you’re up and running, you may have to dive into the terminal to do a few things manually. Rather than blindly follow the directions that you find on forums, read up on the commands a bit. Always know what you’re doing before you type it in.

Pretend to Be the Administrator

One big difference between Linux and Windows is the way user accounts operate. Even if you are the only account on the machine, you are not the root user – and you don’t have access to do a lot of administrative tasks. To do so, you need to enter the root password.

When you’re using the terminal, you preface most commands with the command ‘sudo‘. This tells the terminal that you want to perform this command as the root account – and it will then prompt you for the root password.

Example: sudo gedit /etc/apache2/httpd.conf

Edit a Text File

Another thing you’ll often have to do when working with things in the terminal is edit text files. ‘gedit’ is the command to open the standard text-editing program – gedit. It is a lot like Notepad in Windows. Typing ‘gedit filename’ will open up ‘filename’ in a new window of gedit.

See also  How to Create a Photo Gallery in Microsoft FrontPage

If you’re trying to tinker with your computers configuration, you’re probably going to be editing some configuration files owned by the root user. In order to edit those, you’ll need to use the previous command (sudo) along with gedit.

So, in the following example, you are telling the terminal to open up ‘/etc/odbc.ini’ as the root user. If you didn’t use ‘sudo‘ in the command, you wouldn’t be able to save the file – because you don’t have the proper permissions to.

Example: sudo gedit /etc/odbc.ini

Copy, Rename, and Move

These are three more basic commands that you’ll need. Copy is simply ‘cp filepath filepath‘. Add the appropriate directories and filenames, and you’re good to go.

Example: cp /home/usr/Desktop/resume.odt /home/usr/Documents/resume.odt

Renaming and moving a file use the same command. It sounds a bit odd, but when you get down to it they really mean the same thing. A filename is simply a pointer to a spot on a hard disk.

By renaming a file, you’re creating a new pointer to that spot. By ‘moving’ the file to a new directory, you’re really just renaming it with a new pointer in a different location. The command is ‘mv old_path new_path‘.

Example: mv /var/config.ini /var/config.ini.bak

Working with Directories

Sometimes, you won’t have to change directories at all – you can use the full path (i.e. list all of the directories leading to a file) when you use a command. This is common for most of the commands that you’ll use to edit common configuration files.

If you need to work with directories, though, there’s a few commands to keep in mind.

See also  How to Fix Bing's Dynamic Wallpaper

ls‘ creates a list of the contents of a directory. You’ll see all of the files and directories contained within the directory you are currently browsing. You can also use ‘ls -l‘ to create a detailed list – this shows file permissions (i.e. who can read/write/execute the file).

cd‘ tells the terminal to change directories. ‘cd /var’ would take you to the ‘/var’ directory. You can also use ‘cd ..‘ to navigate up one directory.

mkdir‘ is the command to make or create a directory.

Deleting Stuff

Be careful when using these commands – you don’t want to blindly delete a file that is important for your system.

rm‘ is the command to delete a file. Like with ‘gedit,’ you’ll need to preface this with ‘sudo‘ if you’re trying to delete a file you don’t own.

rmdir‘ is the command to delete a directory. However, this only works on empty directories. If you want to delete a directory and everything in it, use ‘rmdir -r dirname‘ – replacing ‘dirname’ with the directory you want to annihilate.

Good Luck

Linux is a great operating system – good luck in your new adventures. Before you blindly type in a command you find on a support forum, check out what it does.

Be especially careful of commands that contain ‘sudo‘ – that means you’re acting as a root user and you could potentially destroy important files. Likewise, be wary of ‘rm‘ commands – you don’t want to delete something important!

See also  How to Bypass Internet Filters

Reference: