RECENT BLOGS
Pimp Music-6.14.07

Questions of Life-6.03.07

Get Deb-5.21.07



Your Ad Here


Command Line

I was fortunate enough to have taken a class in college for Linux some 5 years ago. Therefore I learned the commands for the command line. Ok so why even bring this up? Well I realize that many people start off with Ubuntu, or any other Linux distro, and they have no idea what to do with the command line. A lot of times they walk through blindly and have no idea what these commands mean. I will now compile a list of very needed commands that you will need to know for your own use at home. The Majority of these commands will Work for all Linux distros. One of them is for Ubuntu only. So here is a list of a few really important commands you should know.

SUDO command:
The sudo command is a very important command for Ubuntu. It's a command that is used in all Ubuntu flavors. This command allows you to do everything in the system that needs root access. The cool thing is you still can log in as root, if you wish. It just takes some tinkering. The sudo command is a nice little security feature in my opinion. So, anyway, if you try to put in a command and it doesn't let you. It is because you didn't use sudo. If your command still doesn't work then you are trying to put in a command that just doesn't exist. The thing to remember is you'll need to type in your password as well. The password is your log-in password. Anyway here is an example of how to use sudo.

CODE

sudo atp-get install gaim

With this command I can download and install gaim (GAIM is a messenger program similar to AIM) through the terminal. This command is something you will use almost constantly.

CD command:
The cd command is for changing directories. When you start off in the terminal or shell you are in your home directory. This cd command can shift you to another one if you wish.

CODE

cd Desktop

As you can see here, with the command, I switched to my Desktop directory. Here I can do any work on my Desktop that I wish through the command line. Let's say I have a folder on my desktop named Pictures. I can now type:

CODE

cd Pictures

From here I can go in and do whatever I wish with my Pictures directory. If I want to go back to my Desktop for anything all I have to type is:

CODE

cd..

This will just take me right back to my Desktop. Or let's say I'm still in my Pictures folder and I want to go back to my home directory all I have to type is:

CODE

cd ~

This takes me right back to the home directory. Let's say I want to go to a directory in some far off place without going systematically like first going to Desktop and then Pictures. It is simple all you need is this:

CODE

cd Desktop/Pictures

Here you can see you are in your Pictures directory.

LS command:
The ls command is for seeing what you have in your directories. It will show all files, including the hidden files. It will also show what directories are in the directory your in.

CODE

ls

All you have to type is that and it will show what you have. So if you are in your home directory (which is where you start when you first open your terminal or go into your shell) type ls. You'll see that you have plenty of things to look at. Including that Desktop directory spoken about before. This is how you know where to go if you are just following a path of directories that are within each other.

CP command:
The cp command is for copying files and pasting them in other places. In order to use this command you also have to use the sudo command. So the example will look like this.

CODE

sudo cp 1.jpg Desktop/Pictures

With this line of command I have copied and pasted 1.jpg to my Pictures folder on my Desktop. The easiest way to use the command is to be in the directory that your file is in. Then you need to know the pathway where you want to paste it. In this case I showed a pathway where I wanted it in my Pictures folder on my Desktop.

MKDIR:
The mkdir command is for making directories. You can do this in the GUI as well by creating a new folder by clicking the right click and going to create a new folder. Sometimes though you will be doing work in the terminal and therefore it is just easier to make a new folder/directory in the command line; or you will be in the shell where you have no choice. Anyway here is an example of how it works.

CODE

sudo mkdir NewFolder

Linux has a bit of a hard time seeing files that have spaces in the names when in the command line. So it's best to just put the words together without any spaces. Anyway this NewFolder will be created in whichever directory you are in.

RM command:
The rm command is a really good command for getting rid of files you don't want. For example, let's say that there is a directory you want to get rid of, and trying to make it go into the trash can doesn't work. All you need is this.

CODE

sudo rm -r directory

Now let me explain this. First you need to know the name of the directory. You can't just type directory like I did. Second the “-r” is kind of like a little helper. It gives the the rm command specific orders on what to do. Basically all commands have this function. You can find out what they are by typing man or info before the command. Here is an example.

CODE

man rm

You will see a little document appear inside your terminal. To go through it either use your up and down arrow keys, or use your Page Up or Page Down keys. To exit the document just type:

CODE

:q

That will get you out of there and back to where you where.

INIT command:
I like this command a lot. I use it to shut down or restart my computer. The thing is you need to know how to do it right. So I will show you.

Restarting the computer:

CODE

sudo init 6

Shutting down the computer:

CODE

sudo init 0

Just for a short reminder. The contents you see in the terminal are different colors as you know by now.
Blue means Directory
Red means zipped file
Green and Pink are usually media files
Green seems to also be programs but I'm not 100% sure on that. It shows up that way for my computer.
Black is usually a text file

I hope this helps everyone who feels a little scared of the command line. Really there is nothing to be scared of. It's really easy after you memorize some commands.





© Copyright Ubuntu Pimp 2007