Linux Tutorial 1
Basic Linux Commands and Concepts
Popular Commands
The number of commands in Linux can fill an entire "thick" book. Do not worry, in this class you will just learn enough Linux commands to complete your web projects. I am not interested in you becoming Linux geeks at this time.
By now, you should be in your Terminal window (Konsole in Linux and Terminal in Macs)
.
Linux files are organized into a hierarchal directory structure. The directory most of you are familiar with now is called /home. Each user, meaning you, has a subdirectory under /home. After you all logged in as guest, most of you found yourself in /home/guest. This is where your personal files are kept.
To verify that you are in your home directory, use the "print working directory" or pwd command:
$ pwd
/home/guest
Your system confirms that you are in /home/guest.
Now, to move from one directory to another, you will use the cd command:
$ cd /usr/bin
$ pwd
/usr/bin
$ cd
A cd with no arguments always returns us to your home directory.
Now lets make a new directory in /home/guest. To do this either type:
$ mkdir programs
or the full pathname:
$ mkdir /home/guest/programs
Now move to that directory:
$ cd programs
$ pwd
/home/guest/programs
To move back up to your home directory, type the following command:
$ cd ..
$ pwd
/home/guest
To remove a directory, type the following command:
$ rmdir programs
Similarly, the rm command deletes files. You can also delete an entire dictory when you use the rm command with the -r option but it can be dangerous.
Listing Files
Enter to the ls command Without an argument, the ls command shows the contents of the current directory. You can include an argument to see a different directory:
$ ls /home
Now type cd to return to your come directory:
$ cd
You the ls -a command to list ALL the contents of the current directory your are in:
$ ls -a
The command ls -al shows all the contents of the directory plus extra information such as file permissions. This will become important as you get deeper into web development.
$ ls -al
By now your entire Terminal window is filled up. Remember, you can use the clear command to clear your terminal display:
$ clear
Typing Shortcuts
Remember, when you press the Tab key as you are typing in the Terminal, it will complete the name of the directory that you are looking for.
$ cd /usr/inc now hit the Tab key
It should complete to:
cd /usr/include
Fun Tools in Linux
To know which user you are currently logged in as, type the command whoami:
$ whoami
To print a calendar of the current year, type the command cal:
$ cal
If you want to print a calendar for December, 2007, type the following command:
$ cal 12 2007
The cal command will work for any month and year.
You have completed Tutorial 1.
Please Note: You can use the above commands in Apple Macbooks and iPhones.