Friday, August 10, 2007

Linux Commands

(Apt) Package management commands
  • sudo vi /etc/apt/sources.list (loads the list of synaptic sources in vi)
  • sudo apt-get install wireless-tools (installs wireless-tools)
  • sudo apt-get update (updates packages from synaptic sources)
  • sudo apt-cache java | grep sun (searches through the apt cache for java grep sun)
  • sudo apt-get install sun-java5-jdk (installs the java 5 package from apt)
  • dpkg --list (displays a list of installed packages)
  • dpkg -l (displays a list of all installed packages)
  • dpkg -S 'name' (find the package containing the executable name provided)

File permissions
  • sudo chown 655 /opt/lampp/htdocs (change the owner of a file)
  • sudo chmod +x /opt/lampp/htdocs (change the permissions of a file)

Finding files
  • locate (searches index for file name)
  • grep -r 'text_pattern' * (Recursive search of all file contents under the current directory for the text_pattern)
  • find . -type f -iname \*.js (finds a type file with a name like *.js (the backslash is escaped)
  • find . -type f -iname \*.fileext -exec grep -nH text_pattern '{}' \;
  • find . -type f -exec grep -nH 'search_string' '{}' \; (Look for a file containing the search string)
  • find -type f -name entries -exec sed -e 's/130\.109\.180\.26/subversion/g' '{}' \; (not sure what the intent)

Mount Windows share as bob and follow the last 100 lines of the log
  1. sudo mount -t smbfs //data/webserver/C$ /mnt/websvr/ -o "username=bob"
  2. tail -fn 100 /mnt/webserver/temp/log/project/log4j_2007-03-02.log

Commands to build/compile from source (TAR):
  1. ./configure
  2. make
  3. sudo make install

Linux partition map
  • / 10 GB (minimum)
  • swap (2GB) - twice the amount of ram, same if ram is above 2GB
  • /home (10 GB)
  • /var (40 GB)
  • /usr (40 GB)
  • /data (remaining/max)

Miscellaneous
  • env (prints all environment variables)
  • tcpdump (??? Research Please)
  • mkdosfs -F 32 -v groveusb /media/usbdisk (formats the disk in FAT32 with a volume label as groveusb)
  • none /proc/bus/usb usbfs devgid=1003,devmode=666 0 0 (entry in fstab for usb devices in virtualbox)
  • ifrename (deprecated in favor of udev)
  • od -tc 1.dat
  • /etc/init.d/vmware start (start vmware daemon)
  • less /etc/modprobe.d/blacklist (prints a list of blacklisted modules Ex. eth1394)
  • mkdir -p /data/projects/project1 (creates each directory recursively)
  • /sbin/ifconfig eth0 address netmask up
  • uname -a (displays the kernel version information)
  • lspci (displays a list of devices)
  • lsmod (displays a list of loaded modules)
  • sudo /etc/initd/gdm restart (restarts the x windows)
  • ps -fade (displays a list of processes)
  • df -h (filesys.info '-h' specifies human readable)
  • sudo vim /etc/X11/xorg.conf (loads the x windows configuration in vim)
  • lsof (Returns a list of previously opened files)
  • ctrl+alt+backspace (restarts X)
  • xfontsel (provides a gui for selecting xfont)
  • xev (runs an input listener for keyboard and mouse)
  • xmodmap -pk (lists the current key mapping)
  • sudo tail -f /var/log/messages (follows the contents of system messages)
  • sudo tail -n 100 /var/log/messages (displays a list of the last 100 lines of messages)
  • dmesg > boot.messages (sends result of dmesg to file)