Franske CNT-2311 SU11 Labs
Revision as of 17:24, 8 June 2011 by BenFranske (talk | contribs) (Created page with "= Session 1 = # Install the Ubuntu Desktop, Ubuntu Server and Fedora Linux distributions into Virtualbox VMs with bridged networking and 768 MB of RAM # Login to the Ubuntu Deskt...")
Session 1
- Install the Ubuntu Desktop, Ubuntu Server and Fedora Linux distributions into Virtualbox VMs with bridged networking and 768 MB of RAM
- Login to the Ubuntu Desktop system and explore the graphical user interface (GUI)
- Login to the Ubuntu Server system
- Create a new directory within your user's home directory and copy the system log file (from /var/log/syslog there)
- Move the copy of the system log file to your home directory
- Make a copy of the system log file to a file with a different name in your home directory
- Delete the system log file from your home directory
- Delete the new subdirectory you created within your home directory as well as any files it contains
Session 2
- Startup and login to your Ubuntu Server VM. Remember that your user account is not an administrator (root) but that some of these commands need to be run as the root user. This can be done several ways but the best practice is to stay logged in as your regular user account and put sudo in front of any command that requires administrative privileges. The first time you do this in a session or if enough time goes by you will be prompted to enter your regular password as verification of your account.
- Review of work with files and directories
- Use the ls command to list all files in your current (home) directory
- Create a new directory inside of your home directory called linuxlabs and another new directory inside of that directory called session2
- Create a new empty file using the touch command inside that session2 directory called firstfile
- Change back to your home directory using the tilde (~) shortcut
- Try using the ls command to list files inside your ~/linuxlabs/ directory without first changing to that directory. You can specify the location to list files after the ls command. For example, to list files in the /var/log directory you could type ls /var/log regardless of what your current working directory is.
- Go back into your session1 directory and create another new file which is a hidden file (to hide a file in Linux you must make the first character of the filename a period). Call this file .topsecret'
- Try using the -a and -l options to get a long file listing for the session2 directory with and without the hidden file being shown
- Pipes, Redirection, Pagination and Searching Through Text Output
- The dmesg command will display the system kernel log, try running it.
- You will notice that there is too much information to display on a single screen and it scrolls off the top of the screen too fast to read. We can have the system paginate the material for us pausing after each screen using the more utility or, if we want more features such as being able to move back and forth through the output, the less utility. How do we get the output of the dmesg program to go through these utilities? One possibility is to redirect the standard output from the dmeasg program to the standard input of the more or less programs. This can be done by piping the output, named that because it uses the pipe character (|). Try doing this by running dmesg | less. Now you should be able to use the space bar, up and down arrows and page up/down keys to move through the output. To jump back to the command line just press the letter q.
- We may also want to save this information to a file. Capture the standard output from the dmesg command by redirecting it into a new file named kernel-log in the session2 folder. This can be done with the standard output redirection character > using the command dmesg > kernel-log. In this case standard error data will still go to the screen but it is possible to capture that instead to either the same or a different file with other redirection characters.
- Let's say we were looking for kernel messages specifically about the eth0 network card in our system, wouldn't it be nice to be able to just pull out the lines that mention eth0? This can be done easily with the grep' program. You can run grep on a file like that kernel-log we just captured but another common way to use it is to search through piped standard input. You can try this by running dmesg | grep eth0 note that if the output is more than one screen in length you can extend that command as needed such as to dmesg | grep eth0 | less which would pause after each screen of information. You can also capture the output through a command such as dmesg | grep eth0 > eth0-kernel-mesgs. Obviously piping and redirection are powerful utilities and commonly used in Linux system administration because of the philosophy of Linux with it's many small and specialized utilities which must commonly be used together to accomplish a useful task.
- Create a backup of files and directories
- Use the tar utility to backup the ~/linuxlabs/session2 directory to a new compressed archive (stored in ~/linuxlabs/) named session2-backup.tar.gz
- Use the rm command to remove the session2 directory and everything it contains, verify this with the ls command
- Restore your gzipped tar file and verify that the files are all back and in the correct place
- Users and Groups
- Try adding two new users, one with the useradd program and another with the adduser program. The two usernames should be gwashington and jadms. You can set the passwords to whatever you like but be sure to write them down where you can refer to them in the future. Remember that you can get help on how to use most commands by checking the online manual with the man command.
- Check the /etc/passwd and /etc/shadow files to verify the accounts were created and note the UIDs for the new accounts. Also check to make sure that the home directories for each user were created.
- Try switching to one of your other virtual terminals by pressing ALT+F2 and logging in as one of your new users and then logging back out.
- Oops! We made a typo in the username of jadms. Switch back to the original virtual terminal and try changing the username and password of jadms' to jadams. You should also try locking the account (HINT: check the manual page of the usermod command for information on this!) and then attempt to login. Unlock the account and try logging in again to make sure it works when the account is unlocked.
- Create a new cntusers group on the system and assign your regular user login as well as the two logins you just created to the group as a secondary group. Verify that everyone is a member of the group by checking the /etc/group file.
- Finally, try deleting the second user you created as well as the home directory of that user. Verify the user is gone from the passwd and shadow files.
- Modify the ownership and permissions of files and folders
- Use the chown command to change the owner AND group of a file and of a directory plus all the files it contains (recursively) somewhere within the ~/linuxlabs/ directory hierarchy
- Use the chgrp command to change just the group of a file somewhere within the ~/linuxlabs/ directory hierarchy
- Use the chmod command to change the permissions on a file or directory somewhere within the ~/linuxlabs/ directory hierarchy using both octal and symbolic modes
- Try using the locate, find, whereis, which and type commands to try finding various files on your system. Remember that some of these utilities use a database of files on your system which needs to be updated from time to time. Some of the filenames you can try searching for are: syslog, interfaces, ls, bash, more, nano, sources.list