CS155: Introduction to Unix

Spring 2018

Commands 4

See this page as a slide show

Unix Commands III

CS155 Commands4

Time Commands

$ date
Sun Dec 22 01:51:03 MST 2024
$ cal
    December 2024   
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 31            
                    
$ cal 11 1957
    November 1957   
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
                    

System Commands

11:32:19 up 9 days, 17:43,  3 users,  load average: 0.00, 0.00, 0.00
  USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
  cs155    pts/0     11:32    0.00s  0.08s  0.00s w
  applin   pts/1     11:32   14.00s  0.08s  0.08s -bash

Finding Things in the Filesystem

% which cat
/bin/cat
% whereis date
date: /usr/bin/date /usr/share/man/man1p/date.1p.gz /usr/share/man/man1/date.1.gz

find

find: Common Expressions

find -name pattern : search for files with name matching pattern. Pattern uses wildcard symbols.

% find ~/pub/ -name '*.t??'
/s/bach/a/class/cs155/pub/dwarfs.txt
/s/bach/a/class/cs155/pub/hw3.tgz
/s/bach/a/class/cs155/pub/domains.txt

find: Common Expressions

% find ~/pub/ -user cs155 -name 'jack.*'
/s/bach/a/class/cs155/pub/hw2Files/jack.info
/s/bach/a/class/cs155/pub/hw2Files/jack.log
/s/bach/a/class/cs155/pub/hw2Files/jack.jpg
/s/bach/a/class/cs155/pub/hw2Files/jack.grades

find: Actions

% 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

find: exec

Miscellaneous Commands

% uname -a
Linux beethoven 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux

% whoami
cs155

Miscellaneous Commands 2

% ping -c1 denver
PING denver.cs.colostate.edu (129.82.44.141) 56(84) bytes of data.
64 bytes from denver.cs.colostate.edu (129.82.44.141): icmp_seq=1 ttl=64 time=0.403 ms

--- denver.cs.colostate.edu ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.403/0.403/0.403/0.000 ms

Printing in Unix

A list of CS department printers: https://www.cs.colostate.edu/~info/printers

Print Commands

Print Commands

% 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

User: Guest

Check: HTML CSS
Edit History Source

Modified: 2018-02-14T09:14

Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2018 Colorado State University
CS Building