*nix

From Things and Stuff Wiki
Revision as of 03:26, 15 June 2012 by Milk (talk | contribs)
Jump to navigation Jump to search


Mainly linux, some unix-like.

Guides

Tools and help

Command line

Finding files

find /usr/share -name README
find ~/Journalism -name '*.txt'
find ~/Programming -path '*/src/*.c'
find ~/Images/Screenshots -size +500k -iname '*.jpg'
find ~/Journalism -name '*.txt' -exec cat {} ;
find ~/Journalism -name '*.txt' -print0 | xargs -0 cat   (faster than above)

http://arstechnica.com/information-technology/2011/07/ask-ars-how-to-use-the-find-command-in-a-pipeline/

Moving files

scp -P 2264 foobar.txt your_username@remotehost.edu:/some/remote/directory [5]

Package management

Apt

Pacman

  • cacheclean - Cleans up pacman packages. Users selects how many old versions to keep.
cacheclean {-p} {-v} <# of copies to keep>
# of copies to keep - (required) how many generations of each package.
-p - (optional) preview what would be deleted.
-v - (optional) show deleted packages.

Disk usage

du -sh
  size of a folder
du -S
  size of files in a folder
du -sk ./* | sort -nr | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'

todo; source aliases.zsh

Time

ntpdate pool.ntp.org && hwclock --systohc && hwclock --adjust
  Synchronize both your system clock and hardware clock and calculate/adjust time drift.
  Do not run this command if you already have ntpd running! [6]

Users

cat /etc/passwd | cut -d: -f 1,3,6 | grep "[5-9][0-9][0-9]"
  List users on a system [7]

GUI

Other software

Arch

Debian

CUPS

X

Window Managers

Openbox

Networking

  • sudo /etc/init.d/<service> restart - ubuntu, restart a service
  • sudo /etc/rc.d/<service> stop | start | restart - arch, service things
  • sudo sh -c "echo 'something' >> /etc/privilegedfile"
  • chown -R user:group . - change all and subitems [8]
  • route -n - display the host's networks and gateway
  • View The Daily Show, etc. in the UK, etc. Mofity HTTP headers; X-Forwarded-For "12.13.14.15" [10]

Cisco

Media

To check;

Chrome