Linux Install and Configuration Hands-On Practice 2
This page is at: http://joelandrebecca.martintribe.org/linuxconf/install/hands_on2.html There is a lot to cover in this session. Go at your own pace but try cover most of the sections at least briefly. Again feel free to work together and ask as many questions as you need. Consult the manual pages for the different commands. It's a steep learning curve, but the knowledge will pay off. Keep working at it when you return home. If you are looking at the web page, then the commands to executed are blue and left justified. Command line hints: - Ctrl-C -> Stop a long running program - Up, Down -> Cycle through previous commands - Shift-PageUp,Shift-PageDown -> Works like scroll bar in the terminal even when scrollbar isn't there. - Tab - Will complete command line if it's obvious - Tab-Tab - All possible ways to complete the current command line will be shown. If run from a blank command prompt, will show all executable programs. Useful Commands Here is a list of commands you may want to experiment around with during this session: cat - print file contents to screen chgrp - change file group ownership chmod - change file permissions chown - change file user ownership cp - make a copy of a file echo - print a text string to screen grep - search a file (or input stream) for a text string ifconfig - show network configuration information kill - terminate a process less - page through ls - directory listing mkdir - create a directory mount - attach a disk partition to filesystem mv - rename or move file to another location passwd - change a user's login password ping - send ping packets to another computer ps - process list pwd - show the present working directory rm - remove a file rmdir - remove an empty directory rpm - package management command sort - sort lines of a file (or input stream) ssh - remote secure shell su - switch user touch - create a file or change modification time umount - detach a disk partition from the filesystem useradd - add a user to the system userdel - remove a user from the system yum - network aware rpm packagement management wc - count the number of lines in a file (or stream) wget - download a file or web page from the internet 1. File system navigation and basics - Show the current working directory pwd - Show the contents of the current directory ls -al - Change to the samba configuration directory cd /etc/samba ls - Show the contents of smb.conf file cat smb.conf - Get to the same direcotry using relative path names cd / pwd cd etc pwd cd samba pwd - Show lines in smb.conf that mention "netbios" grep "netbios" smb.conf - Show number of lines in smb.conf wc -l smb.conf 2. Files, directories and permissions - Return to root's home directory cd - Create a directory called scratch and enter it mkdir scratch cd scratch - Create a file called testfile1 touch testfile1 - List the directory contents ls - List directory contents in long format (extra info) ls -l - List directory contents including hidden files in long format ls -al - Edit the file using the nano text editor, add some text and exit the editor using Ctrl-X nano ls -l - Set the ownership of the file to the apache user chown apache testfile1 ls -l - Set the group ownership of the file to the "users" group chgrp users testfile1 ls -l - Set the permissions on the file so that the apache user can read,write, and modify the file chmod u+rwx testfile1 ls -l - Set the permissions on the file so that users in the "users" group can read the file contents and execute the file, but not modify or write to the file. chmod g+rx testfile1 chmod g-w testfile1 ls -l - Set the permission on the file so that all other users can only execute the file, but cannot view the contents or modify the file. chmod o+x testfile1 ls -l chmod o-rw testfile1 ls -l 3. Package Management with rpm - Situation: There is a package that you find online for doing Non-Linear Video editing. You wish to download the package and install it. You also want learn about what was installed by the package. - The "Add/Remove Applications" GUI tool only applies to applications that are on the install CDs. - The "rpm" command is low level package management command. - Show all the rpms (packages) that are installed on the system. rpm -qa - Search installed packages for packages with "gnome" in the name rpm -qa | grep "gnome" - Download, install the software package "cinelerra" cd wget http://unc.dl.sourceforge.net/sourceforge/heroines/cinelerra-1.2.2-1.i386.rpm ls -l rpm -Uvh cinelerra-1.2.2-1.i386.rpm - Run the program (note that you need to do this from the command line since this package doesn't install links in the applications menu.) cinelerra - Situation: cinelerra no longer runs and you suspect that one of the student admins may have accidently deleted or changed one of the package files. - Get information about the package rpm -qi cinelerra - Show all the files that are installed by the package. rpm -ql cinelerra - Delete one of the cinelerra's files rm /usr/bin/soundtest - Delete one of the cinelerra's files rm /usr/bin/soundtest - Corrupt the main executable echo "blah" >> /usr/bin/cinelerra - Ask rpm to verify the cinelerra package. rpm -V cinelerra - Re-install the application rpm -Uvh --replacepkgs cinelerra-1.2.2-1.i386.rpm - Re-check the package. Note that this command will have no output if the package hasn't changed in any way. rpm -V cinelerra 4. Package Management with yum - Situation: In your readings online, you have found a graphical HTML editor program called bluefish. You have read about the program and it appears to be well-supported and polished. You check and it is not included on the Fedora install media so you guess that the large Dag Wieers repository is likely to have the package. - The "yum" command is a wrapper around rpm that automatically resolves dependecies and downloads packages from yum enabled servers. - Import the Dag Wieers gpg public key. This is used by rpm to verify that the packages that we download from Dag Wieers were actually created at Dag Wieers and not by somebody else impersonating the Dag Wieers site. rpm --import http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt - Now inform yum about the location of the repository. Download a short configuration file into the correct location. cd /etc/yum.repos.d wget http://joelandrebecca.martintribe.org/linuxconf/dag.repo - Show the contents of the configuration file you just added cat dag.repo - Show all the packages that are installed on the system. yum list installed - Search for the package "bluefish" on the yum servers yum search bluefish - Download, install and run a software package yum install bluefish bluefish - Get information about the package yum info bluefish - Uninstall the software package yum remove bluefish 5. Service management - Situation: you wish to activate a web server on your system. - Show services that are installed on the system ls /etc/init.d/ - Verify that httpd (apache's daemon) is in the list ls /etc/init.d/ | grep httpd - Start the apache web server /etc/init.d/httpd start - Get the web server status /etc/init.d/httpd status - Point a browser at http://localhost/ to verify that the server is serving web pages - Stop the web server /etc/init.d/httpd stop - Point a browser at http://localhost/ to verify that the server has in fact stopped - Make the server startup on boot and verify that server is marked on for run level five chkconfig httpd on chkconfig --list httpd - Remove the server from the boot sequence and verify that it is marked off for runlevel 5 chkconfig httpd off chkconfig --list httpd 6. User and group management - Situation: you have a new student that you wish to give access to your system. - Add a user to the system, pick something for USERNAME useradd -m USERNAME - Give the user a password passwd USERNAME - Show the contents of /etc/passwd. Your new user should be at the end of the file. cat /etc/passwd - Use ssh to check if the new user account works ssh USERNAME@localhost id exit id - Remove the user account and all home directory files userdel -r USERNAME - Show the contents of /etc/passwd again. cat /etc/passwd 7. Logging - Situation: you have caught a student looking over your should while you have logged into a system. You want to see - Change to the log directory cd /var/log - Print the security log file to the screen cat secure - Just print the end of the file (most recent entries) tail secure - Print lines that mention the user you created above cat secure | grep USERNAME - Try logging as an nonexistent user three times. ssh zzzz@localhost - Notice a new "failed" entry at the end of the secure log. tail secure - Follow the instruction above and add a user to the system. - Set the password for that user. - Now attempt to log-in as that use but use a false password. ssh USERNAME@localhost - Now list every mention of USERNAME in the secure log. cat secure | grep USERNAME 8. Process Management - Situation: there is a runaway process on the system that you wish to terminate. - Show all the running processes on the system ps aux - Run "Launcher->Accessories->Text Editor" - List processes with "edit" in their name - Find the user id of the process named "gedit" (not "grep gedit") ps aux| grep edit - Kill the gedit process (PROCESSNUM is number from above) kill PROCESSNUM - If that doesn't work, kill with extreme prejudice kill -KILL PROCESSNUM - Notice that the gedit process has dissapeared ps aux| grep gedit - You may also use the program "top" to monitor the top processes by CPU utilization. top - To exit top press "q". 9. Remote management - Situation: you are at home and a student calls you and informs you of a problem with the server. The school is 30 minutes away so you decided to remotely manage the system. - Find a partner, have him/her add a user to their system and visa-versa. Add the user to the wheel group so that the user can switch to the root user. useradd -m -G wheel USERNAME passwd USERNAME - Find out your IP address, the "inet addr" of network interface "eth0". Give your system's IP address to your partner. ifconfig - ssh to your partner's IP address using the user account name that he created for you. ssh USERNAME@IP_ADDR - Switch from that user to the root account. Your partner will have to provide his root password (or type it in for you). su - - Practice doing some of the earlier administrative tasks on your partner's computer If there is time, start looking at manual pages for the commands already mentioned and experiementing with them more. For further reference and study: - Complete this course and you will be on your way to being a Linux command line expert. rute.sourceforge.net - Good Fedora sites: http://fedora.redhat.com/ http://www.fedorafaq.org/ http://www.fedoranews.org/ http://www.fedoraforum.org/ Package Management: - Search for Fedora RPMs: http://www.fedoratracker.org/ - Replace /etc/yum.conf with this one: http://www.fedorafaq.org/samples/yum.conf - Configures Yum to point at fedora.us and livna.org repositories - Yum tutorial: http://www.fedorafaq.org/#installsoftware - Excellent rpm search engine http://rpm.pbone.net/