CS155 Commands4
% date Wed Sep 24 14:04:18 MDT 2014 % cal September 2014 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
date
- Display the current date and time
cal
- display a simple calendar
-3
- Display previous, current, and next month
-y
- Display a calendar for the year
uptime
- information on system load, number of users, and uptime
who
- list of users currently logged in
w
- combination of uptime and who
% w 16:53:39 up 21 days, 22:02, 2 users, load average: 1.00, 1.00, 1.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT applin pts/2 greybull.cs.colo 16:53 0.00s 0.01s 0.00s w dean2026 pts/3 dhcp246.cs.colos 15:29 17.00s 0.33s 0.00s sshd: dean2026
which
- give the full path of an executable
whereis
- search all common executable directories for
binaries (executable files), man pages, source files.
find
– searches the file system for a file or files based on name,
size, when changed, etc.
find
path expression
find
searches recursively from path down looking for files
that match expression.
find -name
pattern : search for files with name matching pattern.
Pattern uses wildcard symbols.
% find ~ -name "*cs155*" /s/chopin/k/fac/boese/mail/cs155 /s/chopin/k/fac/boese/school/cs155 /s/chopin/k/fac/boese/school/BLAHcs155YO /s/chopin/k/fac/boese/school/cs155_logins
find . -name html
html
find . -name "*html"
html
-user
username : file is owned by username
-amin -
n : file access up to n minutes ago
-mtime -
n : file was last modified up to n days ago
% find ~ -name "*cs155*" /s/chopin/k/fac/boese/mail/cs155 /s/chopin/k/fac/boese/school/cs155 /s/chopin/k/fac/boese/school/cs155/cs155 /s/chopin/k/fac/boese/school/cs155/cs155_logins
find
to perform on each file it finds.
-delete
: delete found files (life in the fast lane)
-ls
: give full listing of files
-exec
command : run command on files
% find . -mtime -1 -ls 8798609 12 drwx--x--x 84 applin fac 12288 Jan 1 16:43 . 8799248 4 -r-------- 1 applin fac 395 Jan 1 17:01 ./monster 1246232 4 drwxrwxr-x 3 applin fac 4096 Jan 1 16:43 ./public_html/wiki/cookbook
find . -name "*.bak" -exec mv {} old \;
Search for a string in a selection of files (executing grep):
find . -exec grep "Boese" '{}' \; -print
-exec
action can be very handy.
-exec
is considered part of the command to
execute until a ;
is encountered. The ;
must be escaped by
using \
because it is a special character in the shell.
{}
are replaced by the full path to the found file.
uname
– print system information
-a
: print all information
su
- switch user (login in as different user)
whoami
– get current user name
touch
– change access and modification times of files
bc
– Basic Calculator
ispell
– spell check a file
ping
– check whether another computer is alive
kazoo
or kazoo.cs.colostate.edu
.
tuba
.
A list of CS department printers: https://www.cs.colostate.edu/~info/printers
lpr
– send file to printer without formatting
-Pprinter
: sent to printer
lpr -Ptuba my_file
lpq
– list the printer queue
lpq -Ptuba
lprm
– remove print job
lprm -Ptuba 452
% lpr -Ptuba my_file % lpr -Ptuba my_file2 % lpq -Ptuba tuba is ready and printing Rank Owner Job File(s) Total Size active applin 1016 my_file 1944576 bytes 1st xhua 1021 (stdin) 12432 bytes 2nd applin 1028 my_file2 134144 bytes % lprm -Ptuba 1028 % lpq -Ptuba tuba is ready and printing Rank Owner Job File(s) Total Size active xhua 1021 (stdin) 12432 bytes
enscript enscript -2rGj -d tuba
-2
- 2 columns
-r
- rotate (landscape/portrait)
-G
- fancy header (e.g. date, filename …)
-j
- print borders around columns
-d
printerName - destination printer
Modified: 2012-09-16T15:10 User: Guest Check: HTML CSSEdit History Source |
Apply to CSU |
Contact CSU |
Disclaimer |
Equal Opportunity Colorado State University, Fort Collins, CO 80523 USA © 2015 Colorado State University |