cd - Change Directorypwd - Show Your Current Directoryls - List the Contents of a Directorycat - Print the Contents of a Filerm - Delete a Filemkdir - Create a Directoryrmdir - Delete a Directorycp - Copy Filesmv - Move a File or Directoryecho - Print Text to the Terminalgrep - Finding Strings inside Fileshead - View the Top of a Filetail - View the Bottom of a Filesort - Print a File in Sorted Orderdiff - Differences between Filesdate - Get the Date and Timewhich - Finding a Program Filelocate - Search for Any Filefinger - Get information on Userschmodchmod with Numeric ArgumentslnI have posted homework 7 here.
-h as the help option ...--helpman or infoman or info with the name of the command
& : | * ? ' " [ ] ( ) $ < > { } # / \ ! ~cd - Change Directorycdcd without an argument, it will take you to your home directorycd ..
pwd - Show Your Current Directorypwd will print you your current location in the filesystempwd takes no argumentsls - List the Contents of a Directoryls lists the contents of a directoryls work
ls without an argument ...ls with the -l (long) optionls -a displays the "invisible" files ...cat - Print the Contents of a Filecatrm - Delete a Filermrm *rm will not remove a directory unless you use a special optionmkdir - Create a Directorymkdirrmdir - Delete a Directoryrmdir is used to remove a directoryrmdir will not work unless the directory is emptycp - Copy Filescp copies files or directoriescp with the -r optionmv - Move a File or Directorymv command to move a file or directory ...mvecho - Print Text to the Terminalecho prints text to the terminal
$ echo Hello Hello
echo to print the value of a system variable ...$ echo $SHELL /bin/bash
more and lessless, just to be confusing, has more features than moregrep - Finding Strings inside Filesgrep is used to find all lines in a file ...grep takes two arguments
grep has the following format
grep STRING FILE [FILE ...]
grep on the files in a directory ...-r (recursive) optiongrep -r will search through all files in a directory ...grep, like Unix, is case sensitivegrep ignore case ...-i optiongrep find all lines that do not match a string ...-v optionhead - View the Top of a Filehead prints the first 10 lines of any filehead with a dash, - , and a number
head -20 foo.txt
tail - View the Bottom of a Filetail prints the last 10 lines of any filetail with a dash, - , and a number
tail -20 foo.txt
sort - Print a File in Sorted Ordersort prints a sorted list of the lines in a file ...sort does not change the filesort sorts the lines of a file ...-r optionsort, by default, sorts in alphabetical ordersort -nsort -nrdiff - Differences between Filesdiff compares two files and notes their differencesdiff was created for use with the patch utilitydiff with the -y option to get output that is easier to read
$ head -5 red_sox.txt
2011-07-31 Red Sox @ White Sox Win 5-3
2011-07-02 Red Sox @ Astros Win 7-5
2011-07-03 Red Sox @ Astros Win 2-1
2011-07-04 Red Sox vs Blue Jays Loss 7-9
2011-07-05 Red Sox vs Blue Jays Win 3-2
$ head -5 red_sox.txt | sort
2011-07-02 Red Sox @ Astros Win 7-5
2011-07-03 Red Sox @ Astros Win 2-1
2011-07-04 Red Sox vs Blue Jays Loss 7-9
2011-07-05 Red Sox vs Blue Jays Win 3-2
2011-07-31 Red Sox @ White Sox Win 5-sort does not have an argumentsort requires an argument that specifies the file to sortdate - Get the Date and Timedate command will give the time and the date
$ date Tue Aug 21 10:20:05 EDT 2012
$ date +"%Y-%m-%d"
2012-08-21info or man to see the various formatting options date provideswhich - Finding a Program Filewhich gives the location of an executable fileless is located ...which like this
$ which less /usr/bin/less
which uses the PATH system variable to find the executable filelocate - Search for Any Filewhich and whereis only work on programslocate can be used to find any filelocatelocate will search on a partial file name
$ locate foot /etc/update-motd.d/99-footer /usr/share/doc/java-common/debian-java-faq/footnotes.html /usr/share/emacs/23.3/lisp/mail/footnote.elc /usr/share/emacs/23.3/lisp/org/org-footnote.elc /usr/share/libparse-debianchangelog-perl/footer.tmpl /usr/share/xml-core/catalog.footer /usr/src/linux-headers-3.0.0-12/arch/arm/mach-footbridge /usr/src/linux-headers-3.0.0-12/arch/arm/mach-footbridge/Kconfig /usr/src/linux-headers-3.0.0-12/arch/arm/mach-footbridge/Makefile /usr/src/linux-headers-3.0.0-12/arch/arm/mach-footbridge/Makefile.boot /usr/src/linux-headers-3.0.0-12/arch/arm/mach-footbridge/include /usr/src/linux-headers-3.0.0-12/arch/arm/mach-footbridge/include/mach /usr/src/linux-headers-3.0.0-12/arch/arm/mach-footbridge/include/mach/debug-macro.S ...
locate does not actually search the file system itselfupdatedbupdatedb is usually run automatically in the background to update the databasefinger - Get information on Usersfinger provides information about a user account
$ finger ghoffman
Login: ghoffman Name: Glenn Hoffman
Directory: /home/ghoffman Shell: /bin/bash
On since Wed Sep 17 16:09 (EDT) on pts/1 from dsl092-066-161.bos1.dsl.speakeasy.net
1 second idle
Mail forwarded to glennhoffman@mac.com
Mail last read Thu Sep 4 15:12 2014 (EDT)
Plan:
Office: McCormack M-3-607 Fall 2014
Office Hours: Tuesday & Thursday, 10:00 - 12:00 PM and by appointment
Classes:
IT 341-2 Introduction to System Administration TuTh 12:30-1:45 S3-148 (IT Lab)
IT 244-1 Introduction to Linux/Unix TuTh 2:00-3:15 S3-028 (Web Lab)
IT 244-3 Introduction to Linux/Unix TuTh 4:00-5:15 S3-148 (IT Lab)
IT 244-2 Introduction to Linux/Unix TuTh 5:30-6:45 S3-028 (Web Lab)
Home Address: 40 Central Street 617-821-3936 (home; 9am - 9pm only)
Somerville, MA 02143
finger, like mv, has two functionsfinger shows every user currently logged in
$ finger Login Name Tty Idle Login Time Office Office Phone ghoffman Glenn Hoffman pts/0 Aug 18 11:13 (dsl092-066-161.bos1.dsl.speakeasy.net) rouilj John P. Rouillard pts/1 4:34 Aug 18 06:44 (pool-74-104-161-40.bstnma.fios.verizon.net) ubuntu Ubuntu Dummy *tty1 14d Aug 4 04:53
finger
$ finger Hoffman
Login: ghoffman Name: Glenn Hoffman
Directory: /home/ghoffman Shell: /bin/bash
On since Wed Sep 17 16:09 (EDT) on pts/1 from dsl092-066-161.bos1.dsl.speakeasy.net
1 second idle
Mail forwarded to glennhoffman@mac.com
Mail last read Thu Sep 4 15:12 2014 (EDT)
Plan:
Office: McCormack M-3-607 Fall 2014
Office Hours: Tuesday & Thursday, 10:00 - 12:00 PM and by appointment
Classes:
IT 341-2 Introduction to System Administration TuTh 12:30-1:45 S3-148 (IT Lab)
IT 244-1 Introduction to Linux/Unix TuTh 2:00-3:15 S3-028 (Web Lab)
IT 244-3 Introduction to Linux/Unix TuTh 4:00-5:15 S3-148 (IT Lab)
IT 244-2 Introduction to Linux/Unix TuTh 5:30-6:45 S3-028 (Web Lab)
Home Address: 40 Central Street 617-821-3936 (home; 9am - 9pm only)
Somerville, MA 02143
Login: it244gh Name: Dummy for Glenn Hoffman
Directory: /home/it244gh Shell: /users/nologin
Never logged in.
Mail forwarded to glennhoffman@mac.com
No mail.
Plan:
This account is a test account for Glenn Hoffman teaching it244
gcc ...javac ...pwd (print working directory) command ...ls used with no arguments ...cd with no arguments ...$ cd $ pwd /home/ghoffman
ls does not display these files unless you use the -a option
ls -l
$ ls -l total 5 -rw------- 1 it244gh libuuid 316 2011-09-20 21:32 dead.letter lrwxrwxrwx 1 it244gh libuuid 34 2011-09-06 13:21 it244 -> /courses/it244/s12/ghoffman/it244gh drwx------ 2 it244gh libuuid 512 2011-09-07 15:03 mail drwxr-xr-x 2 it244gh libuuid 512 2011-09-25 15:48 test -rw-r--r-- 1 it244gh libuuid 15 2011-09-20 16:18 test.txt
chmod$ touch test.txt $ ls -l test.txt -rw-r--r-- 1 it244gh libuuid 0 2012-09-17 14:40 test.txt
chmod commandchmod requires two arguments
chmod is
chmod PERMISSIONS FILES_OR_DIRECTORIES
chmod with Numeric Arguments
read write execute
4 2 1
owner group everyone
lscd$ ls -l it244 lrwxrwxrwx 1 it244gh faculty 34 Sep 2 13:10 it244 -> /courses/it244/f14/ghoffman/it244gh
cd into this location and use pwd
$ pwd /home/it244gh $ cd it244 $ pwd /home/it244gh/it244
pwd with the -P (note the capitalization) option
$ pwd /home/it244gh/it244 $ pwd -P /courses/it244/f14/ghoffman/it244gh
lnln with the optionln takes two arguments, a pathname and the name for the link
$ pwd /home/it244gh $ ln -s ~ghoffman/examples_it244 examples $ ls -l examples lrwxrwxrwx 1 it244gh libuuid 28 2012-09-17 17:53 examples -> /home/ghoffman/examples_it244
rm-h, or
--human-readable, option
--help optionecho $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
./PROGRAM_NAME
COMMAND [ARGUMENTS] > FILENAME
COMMAND [ARGUMENTS] < FILENAME
COMMAND [ARGUMENTS] >> FILENAME