How do I find out where I am?

Looking around might help. ;) Seriously though, the way to find out is to type.

$ pwd

pwd is the command and $ is there to represent the command prompt. pwd stands for Present Working Directory. This will give you the full path from /(root) of where you are in the directory tree.

How do I list the files?

OK you have navigated to the directory of choice and need to list what's there. The command is:

$ ls

This gives you a list of all files and directories that don't begin with a . (dot). Some common switches you will use a lot are.
-a (dash a) This lists even the . (dot) or hidden files.
-l (dash l This gives a long listing of files.

For more information type $ man ls and read up on how ls works.

Help I lost a file how do I find it?

Didn't look where you downloaded it to, huh? Don't worry we've all done that one. Linux presents two methods to find a file. (There are other ways, yes, but for now I'll stay with the basics.) They are the commands find and locate.

Now find is a simple utility that will start from where it is and search through every file for the name of the file to be the string you tell it to look for. So if I have a file called "somedangfileilost" and I want to search for it. I would for example in my home directory type

$ find -name some*

This would search for any file that begins with some (the * means match everything) regardless of case.

Now a second way is to use locate. If for example you d/l the file a day or two ago and can't remember the full name or where it is. At the command prompt type.

$ locate some

This will return the full path to any file with a name containing the string some. One note if the cron job to update the locate database has not run since you d/l the file you might need to run (as root) updatedb first.

How do I change directory?

Like most commands it's one that comes from the words describing what you what to do.

$ cd [some directory]

Yep cd is Change Directory. Use the command man cd for more info. Most interesting ones are that if you do cd without anything after it it will go to / and if you type cd ~ (cd tilde) it will go to your home directory.

How do I remove a file/directory?

WARNING: Deleting files in Linux from the command line is for all intents and purposes a permanent action. Do not do this if you think you might want it back latter!
That said the way to remove a file is to type:

$ rm [file name to be removed]

Now in order to remove a directory (empty) type:

$ rmdir [directory to be removed]

The command rm means ReMove and rmdir is ReMove DIRectory. Type man rm or man rmdir for more info on these. I highly recommend adding the following line to your .bashrc file. (unless your run Mandriva, it has this by default)

alias rm='rm -i'

The next time you login to a shell and every time after that when you type rm it will ask for conformation. There is many a time when I thought I was in another directory that this little alias has saved my buns. Typing 'y' isn't so hard to do to confirm. Since Linux removes to a nearly unrecoverable state, it's a good idea to have something there to help. It can be overridden with the -f option. See your man page for more.

How do I create a file/directory?

To create a file you need to touch it. Alright, now wipe the finger prints off the screen and try this at the command line.

$ touch [name of file to be created]

That's it, the file is created. Now in order to create a directory for some reason in *nix you make those.

$ mkdir [name of dir to be created]

Now the question comes, "Can I create a file or directory with spaces in the name?" Yes you can, no you shouldn't.

Why you shouldn't has nothing to do with Linux not being able to handle spaces. Linux sees a space as a break between two objects (strings of text). Since it doesn't use file extensions to decide file type (Which is why you can't lie to the OS about what a file really is.) it doesn't know that something like My file.txt is one file. It will look for 2 files My and file.txt. To work around this you need to put quotes around a name with spaces either to create or delete it.

So the reason for saying you shouldn't? It's easier to to work with a filename that has no spaces.

Where is notepad?

On your windows box. If however you are needing a text editor the follow are some of the many options you have in Linux. First from a command line (shell) there are several options.

  1. ed. This is the original *nix editor and still on the system because it's easy for programs to call it and use it to do automated edits of files.
  2. vi. This is now actually VIM (VI IMproved).
  3. Emacs. The kitchen sink of editors. If Emacs doesn't have a mode to do something you want to do, you forgot to download a package. MIT grads swear by it and VI users swear at it.
  4. Nano. Lightweight like Pico and VI but reputed to be easier to learn all it can do.
  5. Pico. Works and acts a lot like the pine mail client. I'm told there is a connection, I don't have proof.

Now for those who want a gui. There are a bunch of basic editors there too.

  1. kedit. A kde based notepad like simple text editor (with spell check)
  2. gedit. Like kedit but built to work with the gnome suite of apps.
  3. nedit. Another notepad like editor that doesn't play favorites with window managers.

At this point I've covered most of the popular text editors. There are others like kate, Eclipse etc that are aimed squarely at the programmer, but these are more than just ways to edit text.

What is a 3 finger salute?

Don't get kinky. The 3 finger salute is one of the oldest commands in computing. If not they oldest command. It goes all the way back to the days of the original IBM computer Where using the key combination of "Control-Alt-Delete" would cause the system to immediately commence an ordered reboot. Since it takes 3 fingers to do this it can't be done accidentally and has come to be known as "The 3 finger Salute". The nice part about the command is that it will reboot the computer without doing damage to it's files or systems because it is an ordered shutdown.

Until the advent of Windows 2000 this had been true for every keyboard enabled OS ever sold. Now Windows2k 2003-Server and XP use this key combination to start the computer and a start button to gain access to shutting down the computer. If this sounds confusing, good, you are starting to de-Microsoft yourself already. *grin*

How do I shutdown/reboot?

Shutdown (aka turn it off) and reboot (off then back on automatically) are handled as follows.

To shutdown a computer running Linux.

$ shutdown -h now

The -h means halt and the now, well, means now. If you want, you can use shutdown so that it sends out a warning to all logged in users that tells them that the computer will be shutting down for whatever reason in 5 minutes. Use the man page for shutdown for more.

To reboot a computer there are 2 major ways.

  1. Cntrl-Alt-Del, aka the 3 fingered salute.
  2. $ reboot

If you are in a gui just look for the logout and reboot/shutdown links in your menu.

Where are my file extensions?

Linux doesn't for the most part use them. Instead Linux reads the meta data that is created when a file is written to a drive to determine it's type, then it uses something called permissions to determine what can/can't be done with the file.

For an in depth look at permissions this is a decent tutorial. To give you and overview, permissions basically come in 3 forms. Read Write Execute. Each one is set either yes or no. So the 3 things you can do with a file are to read the file (like this page) Write to it (editing) or Execute it. (as in run a program)

Then it's divided into 3 parts User Group World. The owner is whomever is listed, normally this is the person or program that created the file. Group refers to a user group (audio, ftp, users, are some examples) so that others can work with you, sharing a file or device, and World. World is the designation for what can people who don't own the file and aren't in a special group are allowed to do.

If you would like to learn more of what can be done to change permissions on a Linux computer the chmod, chown, chgrp man pages will help.

How do I run(execute) a program?

To run a program just type it's name at the command line and hit the return key. for example

$ ls

Lists the files in a directory. When you are in a graphical environment you can open graphical programs (like firefox) by opening a terminal window and typing in firefox.

How can I tell what a file is?

Sometimes you have a file that, you have no idea what it is. Large drives tend to cause you to keep everything so sometimes that really catchy name you gave a file doesn't wring a bell and you need to find out just what it is.

To find out if Linux can figure out what a file is:

$ file [name of file]

Where file is the command (man file for more). The output will look something like this (depending on file type)

$ file 258
258: JPEG image data, JFIF standard 1.01

Here I've found a file called 258, apparently I hit the return to early and forgot to add .jpg. With the command file I am able to tell me what kind of file it is. Now I can rename it, or open it with the correct program to figure out what it is.

What gives with all the bin/sbin/etc stuff?

How do I install a program?

How do I remove a program?

What is a dot file?

How do I add a user?

How do I remove a user?

How do I copy a file?

How do move a file?