Home COMSC-171 <- Prev Next ->

More Commands

file utilities

wc /etc/passwd # count lines, words, characters wc -l /etc/passwd # lines only wc -w /etc/passwd # words only wc -c /etc/passwd # chars only wc -L /etc/passwd # length of longest line file /etc/fstab # ASCII text file /usr/bin/gunzip # shell script file /bin/ls # ELF 64-bit LSB executable (binary) file /usr/share/man/man1/less.1.gz # gzip compressed data (man page for less) od -ta /etc/fstab # shows non-printing chars as char names od -tc /etc/fstab # shows non-printing chars as C escapes od -tx1 /etc/fstab # shows chars as hex numbers strings -n16 /bin/sh # 16+ consecutive printing chars (in binary file) cat > foo0 # create a file (original) line 1 lime 2 # misspelled Ctrl+d cat > foo1 # create another file (new and improved) line 1 line 2 # corrected Ctrl+d diff foo0 foo1 # show differences between two files (line editor format) diff foo0 foo1 | tee foo01.diff # create and display update file cmp -l foo0 foo1 # binary compare, -l shows which bytes differ rm foo0 foo1 foo01 # clean up

system info

hostname # shows hostname uname # shows UNIX name uname -a # (all) shows more information uptime # shows how long the system has been running and CPU load averages quota # shows disk quota (if any) on your account df -h # shows disk space free in each mounted filesystem, human readable du -hs /etc # shows disk space used in specified directory du -ks /etc 2> /dev/null # kilobytes, discards error messages vmstat -d # disk status vmstat -SM # memory status (MB) free # memory, Linux only ip addr # interface addresses ip route # routing table ip neighbor # same LAN

user info

whoami # shows your login name id # shows UserID, GroupID, and groups users # (similar to who, finger) shows users logged in w # shows uptime, users logged in, and what they're doing finger $USER # this shows information about you finger stuart # this shows another user last | less # shows recent logins q # quit less ac # accounting, total connect time in hours ac $USER # your connect time ac -p # every person's connect time ac $USER -d # your connect time by day

dates

date # shows time and date date +%s # seconds since epoch (1970 Jan 01), many other format options cal # shows calendar for current month cal 5 2026 # shows calendar for May 2026 cal 2026 | less # shows calendar for all of 2026 CE q # quit less

fun

fortune # shows a random fortune cookie