CS155: Introduction to Unix

Spring 2018

Commands 4

See this page as a slide show

Unix Commands III

CS155 Commands4

Time Commands

$ date
Wed Apr 17 21:01:19 MDT 2024
$ cal
     April 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            
                    
$ 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/domains.txt
/s/bach/a/class/cs155/pub/dwarfs.txt
/s/bach/a/class/cs155/pub/hw3.tgz

find: Common Expressions

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

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-513.18.1.el8_9.x86_64 #1 SMP Thu Feb 22 03:02:37 EST 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.188 ms

--- denver.cs.colostate.edu ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.188/0.188/0.188/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