Lab Two - Basic Linux Commands

The purpose of this assignment is for the student to learn some basic linux commands necessary for survival. Specifically, viewing a file's contents, basic directory commands, and simple man pages.

The tables below summarize the commands you need to know to get started (and to do today's assignment).

Step One: Read through Chapter 5 and Chapter 6 to learn about basic utilities and the linux file system.

Step Two: Experiment with each of these commands:
          mkdir
          rmdir
          cd
          ls
          pwd
          cat
          head
          more
          rm
          cp
          who
          date
          cal
          man

Step Four: Create a log file (see script command in lab one) showing how to do each of the following tasks:
1 - type the command whoami
2 - create a new directory named lab2
3 - change directories into lab2
4 - list all files, even hidden files (directory should be blank)
5 - create a new file that contains the calendar for this month
6 - list all files again, even hidden files (there should be just one file)
7 - display the entire contents of that new file
8 - delete the file
9 - ask the system when is easter in 2012
10 - aks the system for today's date
End the log file.

Print the log file and turn it in at the beginning of the next lab period.


Directories

mkdir xyz make the directory xyz
cd xyz change directory, down into xyz
cd .. go up one directory level
cd ~ go to your home directory
cd ~dannellys2 go to dannelly's home directory
ls list the contents of current directory
ls -a directory listing, including all hidden files
ls -l directory listing, show permission, edits dates, etc.
ls -al really long directory listing


File Manipulation

cp file1 file2 make a copy of file1 named file2
cat myfile show contents of myfile
more myfile show contents of myfile one screen at a time
head myfile show the top 10 lines of myfile
rm myfile remove myfile (delete it permanently)
rm * remove all files in current directory
rm -i * interactive removal - ask yes/no for each file
ls > bob redirect directory listing into the file named bob


Misc Commands

who users logged into this machine
date today's date
cal calendar (many options)
man -k calendar list manual pages related to calendar
man cal manual page for the "cal" command
exit logout of system
logout logout of system
ctrl-d logout of system
ctrl-c kill the running program


Note: Accidental file removal is a common problem.  I highly recommend that you edit the .bashrc in your home directory to include the line alias "rm=rm -i" Be sure to add that line after the first line of the file and before that odd looking if statement (if you have such).