I guess you all have worked on the Linux prompt some time or the other.
For most of you, it is the following prompt that appears when you telnet
to www.pes.edu to change your password.
www:~$ _
If you don't know what telnet is our how to change your password,
or what the hell Linux is, this is the place for you.
If you know what Unix is, skip to the next paragraph. Way back around 1965-70, the need arose for having an operating system which could handle more than one user spanning more than one computer accessing common resources and being able of flawless communication. Thus, Unix was developed with the idea of having one OS capable of handling just about everything. The foresight of the developers of Unix is to be admired as that led to the creation of a powerful OS, that till today has not lost its charm and usefulness. Agreed Unix was never considered user-friendly and for the masses but it was respected nevertheless. A person who worked on Unix was considered an expert on computers. He still is. The Internet still runs on a framework with its origins in Unix. In other words, Unix is invincible.
Linus Trovalds, a student studying at Helsinki University wanted to try and get a port of Unix on the PC platform. He developed a kernel (the core of an OS) and unlike Unix, he let it free. Not just the program but the source code as well. Linux spread like wildfire and programmers throughout the Internet sent in their contributions. Linux grew at an amazing rate, and although it is a very powerful platform, it is quite happy with even a 486. Think of Linux as a true Unix now, not just a toned down one.
The power a Unix platform has to offer is just amazing and deserves a good amount of reading. What we have set out to do here is to create a user's guide and that is what we shall do. I assume the reader has a fundamental knowledge of DOS.
1) Your prompt:
---------------
In dos, you probably had a prompt that said
C:\DOS\>_In Linux, you would have the following prompt:
www:~$ _(Underscore shows position of the prompt)
C:\DOS\>This tells us the current drive is C:, and we are in the DOS directory.
www:~$'www:' tells me the name of the machine in the networked environment is 'www'. For e.g.., the pes.edu domain belongs to pesit and hence, the machine called www internally will be referred to as www.pes.edu from the outside world. Make sense?
C:\DOS\>DIR /W/P <---DOS Command
www:~$ ls -al <---Linux Command
The '$' is your prompt. The Linux shell is telling you that it is
ready to accept your command. Also, the $ specifies that you are an ordinary
user. The super user or the administrator, called root has special permissions
and his importance is indicated by a # instead of a $. Thus, root has the
prompt www:~#
2) Directories.
---------------
In DOS, dir is probably the most used command. Its equivalent in Linux is ls. People have asked me what the hell ls is and that it makes no sense at all. I have always told them thus: ls stands for list (If anyone knows what ls actually is, please mail me at sush@pes.edu). And if you are not a DOS user, you would think "Something like 'files', 'showfiles' or 'listfiles' ,etc makes more sense. What the hell is dir?"
By the way, dir also works except for the switches.
The output of ls is similar to that of dir/w . If a file has an asterisk next to it, then it is executable. If you would like info about each file, then use ls -l (l for long). This will give you more information about each file.
In DOS, if you want to hide a file, you would do
ATTRIB +H WHATSUP.DOCIn Linux, any file starting with a period is considered hidden. Linux does not use extensions and the period is considered just like any other character. Thus, I would just name the file or directory to be hidden starting with a dot. e.g..: .whatsup.doc
In DOS, DIR /A brings up the hidden files as well. Similarly, in Linux, ls -a ( a for all) brings them up.
In DOS, to have multiple switches, you would do
DIR /A/PIn Linux, one hyphen is enough:
ls -al
Q) How do I create a directory?
A) Use the mkdir command. No! md will not do it. It has to be mkdir!
e.g.:
www:~$ mkdir www
Q) How do I change between directories?
A) Use the cd command. Are the DOS users right at home?
www:~$ cd wwwAs in DOS, cd .. takes you back to the parent directory.
www:~/www$ cd ..
www:~$
Q)How do I remove directories?
A) You will learn the rm command later where this will be detailed.
Q) Help! My prompt reads www:/$ and I cannot find my directory!
A) You went to the root directory i.e. www:/ . No problem. Goto /home/username
(/home/sush in my case) and you will be in your directory. Also,
cd
~ will do the job (Remember I said ~ represents the home directory?)
Note: Anything you put up in your www directory will be visible in http://www.pes.edu/~username
after you give it correct file permissions (SEE chmod)
A word of Caution: LINUX IS CASE SENSITIVE! This means that typing
LS or lS or Ls instead of ls just wont cut it. Same with everything else.
If you have a directory called 'Mail' and you are trying to 'cd mail',
things just wont work. Another side of this is YES, you can have directories
called mAiL, mail, MAIL, Mail....etc. in the same directory. Go figure!
3) Files
--------
3.a) The cp command:
cp file1 file2What does this look like? If you've used copy, further discussion is not of much use.
3.b) The mv command:
mv file1 file2mv is for move. Also, mv is used for renaming files as well. There is no dedicated command for renaming. Experiment!
3.c) The pico command:
picoUse pico to edit and create files.
3.d) The cat command:
cat stands for concatenate and further explanation could be confusing
for the novice user. Just know this:
cat file1This command types out the contents of file1.
cat > file1This is like copy con file1 in DOS. Use ^D for EOF as you would use ^Z or F6 for EOF in DOS
3.e) The more command:
You've probably used 'more' in dos:
type hugefile.txt | moreThe same exists in linux in the same way.
more hugefile.txt
cat hugefile | more
more hugefile
3.f) The less command:
The creators of linux always had a wacky sense of humour (I love it!).
So, when they had to extend the more command and give it more functionality(
i.e. more than just plain ol' more, get it?), they called it the less command.
It is used in the same way:
cat hugefile | less"What's so great about less?", you ask. You can not only view a huge file page by page, but also scroll up and down it by using the up and down keys. I've never used more after that and using cat in conjunction with less is plain dumb. I just use less hugefile.
less hugefile
4) Permissions
-------------
Here come the heady stuff. Meek people can back off right now, and never
create their own web page. Unix has always been a multi-user operating
system and keeping one's files away from other people has always been on
the top of priorities. There are three types of permissions, applying to
three different types of users.
The three types of permissions are Read, Write and Execute.
The three types of users are the Owner of the file, The Owner's Group
members, and the Rest of the World (sometimes called Others ).
For e.g.., a person might want to create a file that he does not want others to modify. So he gives write permission only to himself. He might not want the rest of the world to read it, because it is confidential but he doesn't mind his colleague reading it. If the colleague is in the same users group ( All PESIT students are in the Group called users ), he could give read permissions to himself and to his group but withhold read permissions for the world.
The third permission i.e. Execute permission tells Linux that the file is executable. Say for example you are programming something new and still debugging it. Then you give Execute permissions to yourself and withhold execute permissions of that file for everyone else.
Note: For anything to be accessible to a web browser, it must have Read and Executable Access set for the rest of the world. As far as Linux is concerned, the web browser is executing your web page(*.html) .
Q)All this is understandable but how do you set permissions for a file?
A)The chmod command is used for this.
Just remember these values.
Read=4
Write=2
Execute=1
If I want to give a file read and executable access, then I give it
a permission value 5 (=4+1)
If I want to give all three permissions, then I give it a permission
value 7 (=4+2+1)
and so on
I decide what permission numbers to give for myself, my group and the
rest of the world. Let these numbers be p,q and r. Then the chmod command
goes thus:
chmod pqr file1That's it.
The most common access numbers are 755 and you must give every file in the www directory these permissions. You must give the www directory itself 755 permission if it is to be accessed through a browser.