A Newcomers Guide to understanding Linux By Penfold 1: Introduction 2: Basic Walk Around 3: Commands & Permissions 4: X Windows 5: Extra Commands and Configuration 6: Installing 7: Conclusion Introduction Linux is an open source Unix Like Operating System that was created to give everybody a chance to work in an Unix enviroment without the commercial fee. As a first attempt to create a non-commercial unix distrobution, minix was created. It had minimal Unix Features. Shortly after Linus Torvalds became a primary devleloper of a new operating system which was to be known as Linux. Since then along with the 'free' BSD varients, Linux has become the leading non-commercial Unix and has expanded a network of programmers who strive to work on a more stable kernel and features. One of the primary reasons as to why many people have switched to Linux is due to it's stability, security and a large community of dedicated programmers who take vast amounts of time out of their personal life to write software freely for Linux. Although their is fierce competiton and even some small scale disliking of Linux & BSD users to each other, they both have the same primary goals. There are also some semi scaled disliking of Linux users between each other. Many users tend to brag down onto new users of their knowledge and modesty between each other is very scarce. If i can say one thing for certain, it is not to brag about anything to anybody. Be modest about your knowledge, you will be respected alot more during your idling on IRC. Firstly this paper is not aimed at extreme technical linux issues but the bare basics to get linux users aquainted with the linux operating system. It is also been wrote on the little spare time that i have so it is not aimed as a reference book or study guide either. Remember that linux is not too user friendly to start off on, but once you have grasped the basics, it will all fall into place, so learn how to utilise this powerful operating system and work to make it better. Any typographical errors are due to lazyness :) Basic walk Around So you have just installed your first Linux Distribution and you have clearly no idea on what to do from here on in. Assuming you have a basic grasp on the bash shell and minimal Linux lingo i can procede to take you through some various tips that will increase your knowledge in a Linux enviroment. Take into account that i am working on Slackware Linux 8.0 on the 2.4.19 kernel at the time of writing this. Linux to a new user can seem somewhat confusing and configuring can seem to be much more hassel that it's worth, but don't leave a complicated looking area put you off. It resembles a mathamatical problem. At first the problem seems to be confusing but the more times you read and look over it, the more clear it becomes. This also applys for linux. You have got to look at an operating system as the means of an 'interface' for you the 'user' to communicate with your system. Without an operating system, your computer would be almost obsolete. Linux provides two Interfaces for you communicate with your system. The standard text based Interface (UI) and/or an X windowing system (GUI). The standard UI is what you see when you spawn a linux command line shell. It is a simple (yet powerful) means of passing commands and arguements which are in turn broken down for your system for communication purposes. The most common UI used would be a BASH shell, their are many more different shells but it is not important at this time. Your alternative inteface is your X windowing system which provides a means of a drag & drop desktop area with graphically based features for you the communicate with your system. Xfree86 is standard for Linux and comes with a variety of free managers such as Gnome, KDE, Enlightenment, ect. Putting it into perspective that these are only a means of communication between you and your system, you can understand why you shouldn't get too put off by what may seem a complicated matter. These Interfaces have been wrote by technically sound programmers to ensure you have a simple way of communicating with your system. Commands & Permissions You will first notice when you install Linux that the directory structure differs to dos (taking for granted that you have previous dos knowledge). Standard default users directories go by /home/username This is where all your personal files will be stored if you are a standard user. As root your home directory will be /root defaultly. To find out your exact home directory, just do the following. cd pwd The last two commands will change directory to your home directory and print the working directory (pwd). You should come up with something similar to this. /home/penfold *Note*: Home directories can be modifed, these are just where they lay by default. Now upon entering your home directory, this is where you can store all your personal documents, similar to a 'my documents' directory on windows. You can create subdirectories inside your home directory as you please. The linux file structure totally differs than that of your standard windows directory structure. Remembering two golden rules will be a head start for you and navigating around a linux file structure. The first golden rule is that everything on a Linux system is case sensitive. If you create a directory 'public_html' and Public_Html', they are totally two seperate directories. Even your login and password is case sensitive. The second golden rule in a linux file structure is that directories and subdirectories are seperate by a '/' oposed to a windows '\'. So should you be changing a directory, remember not to confuse yourself with windows backslash directory seperation. The linux command line also differs to that of windows. the command line is much more powerful than the windows command line and many commands have extensions onto a command. Take for example a simple file list command. [penfold@phenix penfold]$ ls homepage Mail You will notice that it has dumped the output of the directory listings. Now lets extend the 'ls' command. [penfold@phenix penfold]$ ls -a . .alive .bash_logout .bashrc .lastlogin .mh_profile .. .bash_history .bash_profile homepage Mail .ncftp You will now notice that hidden directorys and files (which are determined by the period) are also listed. Lets extend the ls command one more time. [penfold@phenix penfold]$ ls -al total 264 drwx--x--- 5 penfold www 4096 Jun 13 02:23 . drwxr-x--x 10877 root root 225280 Aug 21 07:17 .. -rw-r--r-- 1 penfold free 0 Aug 21 18:35 .alive -rw------- 1 penfold free 3558 Aug 18 18:21 .bash_history -rw-r--r-- 1 penfold free 24 Mar 28 07:36 .bash_logout -rw-r--r-- 1 penfold free 224 Mar 28 07:36 .bash_profile -rw-r--r-- 1 penfold free 174 Mar 28 07:36 .bashrc drwxr-xr-x 5 penfold free 4096 Aug 18 18:20 homepage -rw-r--r-- 1 penfold free 656 Aug 21 18:35 .lastlogin drwx------ 2 penfold free 4096 Jun 13 02:23 Mail -rw-r--r-- 1 penfold free 11 Jun 13 02:23 .mh_profile drwxr-xr-x 2 penfold free 4096 Mar 29 02:16 .ncftp You will now notice that it will list all files and directorys, including file permissions, date and time. You don't need to know about the file permissions just yet, but take into account, should you need to list files in a directory including the permissions of each file and directory you can use the '-l' extensions onto 'ls'. What if i was to list all non-hidden files and directories. Lets take a look. [penfold@phenix penfold]$ ls -l total 8 drwxr-xr-x 5 penfold free 4096 Aug 18 18:20 homepage drwx------ 2 penfold free 4096 Jun 13 02:23 Mail You see the Mail and homepage directories listed once again, but this time the file permissions and other information is listed but because i have not used the ''-a" extension, the hidden files and directories were not listed. You will notice i have constantly been blagging on about 'file permissions' and not yet explained what they are. File permissions on a linux system can make it the most secure operating system going, or the weakest, depending on how you set them up correctly. A badly permissioned linux system can be comprimised within minutes so it is best to take into account that file and directory permissions are very important when it comes to the security of linux. Take into account that you have a file. You also have different users and groups a linux system. The superuser of the whole system is root. Then after that you will have various other groups which will have different permissions for each directory and file. Root will have access to whatever he or she please while other users will not unless otherwise specified. Lets go back up and take a look at the directory 'homepage'. You will see the following drwxr-xr-x 5 penfold free 4096 Aug 18 18:20 homepage Look at the very first segment. drwxr-xr-x The very first character which is a 'd' means that it is a directory. If there is not character there it will mean it is a file. You will then see the next three characters. rwx This means that the owner of this directory would have read, write and execute access, hence the w,r,x. The next three segments are for group, in the case it would be the 'free' group. r-x Anybody in the 'free' group would have read and execute privilages to this directory, but they would not be able to write to it. Then onto the last segment which is known as other, meaning any other user. They would also have read and execute access like the group 'free' did. r-x I suppose by now you have figured out the owner of this directory and the group he lays in. penfold free The owner is 'penfold' and the group is 'free'. But what happens if we wish to change the privilages of this directory ? Maybe we don't want anybody but the owner to have read, write and execute access. We can then perform the 'chmod' command, which changes file and directory permissions. We can step through the chmod command relatively easily so you can change the file permissions in any way you see fit. Take into account that 'read' access is given a value of '4', 'write' access is given a value of '2' and 'execute' access is given a value of '1'. So how can we implement these values into the command ? As following chmod 700 homepage We have now given 'owner' read, write and execute access to this directory. The group 'free' and other will have no access to this directory. You will notice the value of 700 given to this directory. Lets break this down 7 which is the value given to the owner of the directory. If we look back up to our values for each permissions we will see that read (4), write (2), and execute (1) add up to 7. You will then see that the second segment which is group has a value of '0', which would give it no read, write or execute access as with other. Just think of read, wrtie and execute accesses as a book. To open the book you will need execute access to it. To read the book, you will need read access to it, and to write onto the book you will need write access. Also as a system adminstrator, sometimes you will need to change either group id or ownership of a file. Two new commands you will learn for this are 'chown' and 'chgrp'. chown will change the ownership of a file while 'chgrp' will change the group id of that file. See the man pages for chown and chgrp for options on these two commands, i would go into detail about these commands but it is beyond the scope of this document. X Windows After installing xfree86 you will need to know how to fully configure your x windowing system and modify window managers. Taking into account that i am currently working with Slackware Linux 8.0 during the time of writing this, some distros may vary in extra x based applications. Upon setting up xfree86 you will need ot learn how to fulyl configure it, for mice, monitor resolution, video memory, graphics based drivers ect.. To fully configure this we can use the 'xf86config' command (ensuring it is in $path). This will run the xfree86 configuration script and will enable you to fully configure your xfree86 release. Before running this you will need to know a few details on your spec beforehand. Firstly you will need to know what release mouse you have and where it's drivers resides. For example you could have a ps/2 mouse with two buttons. You will be asked which kind of mouse you have. Choose: ps/2 You will be then asked if you wish to emulate a third button. Choose: Yes Then you will be asked for the location of ps/2. Input: /dev/psaux Your mouse is now fully sorted. You will also need to know your grapihcs card set and how much video memory you have before running xf86config. If your card is not supported, you will need to refer to the manufacturers website for drivers. Also you will need ot know your keyboard type and what style format you wish to use for keypress. You will also need ot know your monitor's specs, sync rate and which resolution you wish to choose as your primary resolution. The xfree86 configuration application is not complicated and if you make a mistake during configuring, don't owrry, nothing too drastic will come out of it, you can always run it again and again. You will notice that some distros of linux don't have the so called user friendly drop and choose GUI (Graphical User Interface) based window manager choosing screen. To modify our window manager without our fancy GUI screens we will need to edit our '.xinitrc' file in our home directory. Now this may seem somewhat scarey at first, but don't be frightened by it. It is a simple script that runs our chosen x windowing manager from 'startx'. The only line you will need to modify is the very last line. As an example if you are currently running blackbox you should see at the bottom of the script: exec blackbox To change it to any other installed windowing managers, just edit that line ot that of the windowing manager. For example if you wished to run enlightenment as a default window, just change the last line to: exec enlightenment It is really that easy, on slackware you will also have a utility that can be executed by running 'xwmconfig' from your command line that will do the exact same thing but with a simple menu utility instead. The just run 'startx' and providing everything is perfectly configured, your window manager should start up. Extra Commands & Configuration When running an application or utility, it will have a process id. Essential for 'killing' a chosen application at will. Sometimes a program will become unstable and even hang, you can use the kill command to kill an application. Firstly we will have to use the 'ps' command to list all processes running, there are many more tags onto the ps command, such as ps -x (will list processes running under x windows) ps -u username (list processes of that user) ect... Refer to the man page for ps for further info. Upon finding our targetted unstable program we can use the 'kill' command to end it. There may be other complications that will keep the application restarting everytime you kill it so we will have a look into that in a short while, for now though i will take you through the very basic 'kill' command for ending an application. Once you have found a problematic application, you can use kill to shut it down. You may use the 'top' command to check for cpu usage: [penfold@phenix penfold]$ top 7:06pm up 39 days, 2:55, 49 users, load average: 0.19, 0.21, 0.19 2 processes: 1 sleeping, 1 running, 0 zombie, 0 stopped CPU states: 2.9% user, 0.5% system, 0.0% nice, 96.4% idle Mem: 125344K av, 117528K used, 7816K free, 0K shrd, 4672K buff Swap: 265032K av, 24716K used, 240316K free 59416K cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 28653 penfold 14 0 1020 1020 840 R 0.1 0.8 0:00 top 8362 penfold 12 0 1256 1256 976 S 0.0 1.0 0:00 bash Any application that deems to be problematic and is using up more cpu and memory than usual, may signal that the application is putting your system under strain, it may hang and you will have no other option only than to kill it. The top command is very similar to the ps command but it shows more information standardly. If i run the ps command we will see that it shows both of the processes running also. In this case, the top process has been switched with the ps process as the top command is no longer being used. 8362 pts/31 00:00:00 bash 26352 pts/31 00:00:00 ps Should we have a problem in any of these processes we just run kill and the id of the process. For example: [penfold@phenix penfold]$ kill 601 Would kill a process if it's id was 601. The process would shut down and your kill command would be complete. The kill command can be very useful but sometiems it may be needed to kill the parent of a process in order to shut it down. For this we can use the 'ps -l' command to list processes and their parent process. We should only need to do this if the kill command will not keep the process closed permantly until we reopen it manually again. Lets have a look at the ps -l command. [penfold@phenix penfold]$ ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 100 S 18099 8362 11401 0 75 0 - 609 114e04 pts/31 00:00:00 bash 000 T 18099 15645 8362 0 69 0 - 426 106a90 pts/31 00:00:00 man 000 T 18099 9588 15645 0 69 0 - 554 106a90 pts/31 00:00:00 sh 040 T 18099 9820 9588 0 68 0 - 554 106a90 pts/31 00:00:00 sh 000 T 18099 17308 9820 0 69 0 - 508 106a90 pts/31 00:00:00 less 000 T 18099 10706 8362 0 69 0 - 426 106a90 pts/31 00:00:00 man 000 T 18099 11128 10706 0 69 0 - 554 106a90 pts/31 00:00:00 sh 040 T 18099 8704 11128 0 68 0 - 554 106a90 pts/31 00:00:00 sh 000 T 18099 32158 8704 0 69 0 - 508 106a90 pts/31 00:00:00 less 000 R 18099 2160 8362 0 78 0 - 660 - pts/31 00:00:00 ps We will see a new section showing PPID, which is the parent process id of that process. We can then kill that process issuing either the kill command or the more disfunctional kill -9 command. Kill -9 kills the application straight away without any neat and tidy shutting down of the app like the kill command. Either way, you should take into account only to go this far if a process continues to be troublesome and can not be killed straight away with the kill command. Installing One thing you will notice about Linux is that you don't have handy setup.exe files to automatically install an application for you, but there is an alternative to the windows setup files. The alternative is what is called a Package manager. the most common package manager is Rehat's RPM (RedHat Package manager). There are also some alternitives but at the moment, package managers are pretty straight foward to use so i will show how to install without using them, Afterall, you should try get out of the routine of an operating system babying you all the time. As you being to download applications, you will notice that most are held in what is called a tarball. A TarBall basically holds all the files in one file, much similar to the zip concept but without the compression. To compress a Tarball you will need to gzip it. Tar files alone have a .tar extensions and a gzipped tarball has a .tar.gz extension. These are the most common extensions you will see. To untar a tarball just issue the following command: tar -xvf filename.tar Also as i said previous the file may be gzipped so you will need to extend the command to: tar -xzvf filename.tar.gz For more information the tar command just issue 'man tar'. Usually upon untarring the tarball you will be presented in the primary directory with a configure file. Noting that it can vary, take into account to read the INSTALL or README files that come with it. Just issue the following to read them. cat txtname | more The more extension will allow the buffer to pause until a return is entered so you can read long files. You can also use the less command to read the file. Should you see a configure file, which you usually will, you can just execute it with a ./ like you would any other file. Make sure it has executeable permissions for you, if not you can just chmod the file to allow it to be executable. Upon execution, by standard, just run make and then make install. The whole process should look like this. [penfold@slack3r]$ ./configure [penfold@slack3r]$ make [penfold@slack3r]$ make install It's pretty straight forward, take into account to always read the readme or install files, just incase the install procedure may vary. Don't let what may seem a complication to be complicated, it is straight forward and nothing can go wrong. Taking into account that you are running a RedHat Package Manager and utilising it in a command line cased format you can install by using the rpm command. [penfold@phenix penfold]$ rpm -i package-filename The above would install a rpm based package. There are alot more options to installing such as rpm -F to upgrade a package but that is beyond the scope of this text. Should you at some time get fed up of a package and wish to install it you can use your rpm command to uninstall. [penfold@phenix penfold]$ rpm -U package-filename You can also list the files in the package should you need to check before installing once again with the RedHat Package Manager. [penfold@phenix penfold]$ rpm -l package-filename There are alot more extras to the RedHat Package manager but i'm sure you can utilise the man command for more information should you ever need to. After installign straight from using Microsoft Windows Or Mac all your life, some of the above may fighten you somewhat, but don't worry, what may seem a complicated set of tasks is merly more than an trick of the eye. Everything requires practice and practice makes perfect. Somebody once said "If practice makes you perfect, and nobody is perfect, then why practice", I say that is a motto of the fool. Always give your all into everything you do, there isn't anything on this world that you can't accomplish if you try and want it hard enough..... Conclusion This may not be the most technically sound guide ever wrote but it was wrote on my spare time, i am (and this may be somewhat of a contradiction to this whole guide and myself) currently studying for my Microsoft Certified Professional in Both Visual Basic (Yup it is a resource hogging bitch language with no power of cross platform abilities) and Windows 2000 Professional (It's not a Bad operating system people. There is alot more to it when you learn to utilise all it's features). So the sum it up, i am a very busy person who has alot on his mind but i still deliver to you, my walkthrough of linux basics. I hope it to be somewhat of an educational guide and i apologise to any Linux gurus who may be bored by some primative and basic Linux maintenance information, but you must remember, it is never that basic for somebody who has just installed their first distro :). I do plan on revising this text at some stage in the future so keep your eyes open. I suppose it would be tradition to give a few shout outs to a few friends so here it goes: My Coding Collegues at Smart-dev.com The minimal few people i still know at Hackers.com The Idlers of systemloop.net's ircd The host of my shell & website at systemloop.net Psycho Staff of slackroot.com And to save time naming out the 6 gizillion people i know, everybody who knows me Date: September the 19th 2002 Mail: Penfold [at] slackroot [dot] com Web: http://penfold.systemloop.net