Linux Commands

From HyperSecurity Wiki
Revision as of 04:13, 23 September 2009 by 174.6.196.93 (talk) (Linux Commands)
Jump to: navigation, search

Linux Commands

  1. RPM Version Info:
    • rpm -qa foo
  2. Shutdown X11:
    • init 3
  3. Reboot the System:
    • init 6
  4. Mount a CDROM:
    • mount /dev/cdrom
  5. Unmount a CDROM:
    • umount /dev/cdrom
  6. List Start Up Scripts:
    • chkconfig --list
  7. Turn On Start Up Script:
    • chkconfig service start
  8. Turn Off Start Up Script:
    • chkconfig service off
  9. Get the kernel version by typing
    • uname -r
  10. Format USB Device to Vfat
    •  mkfs.vfat -F 32 /dev/sda1
  11. How to create tarball's assuming your directory is called foo:
    • tar -cvzf foo.tar.gz /dir/foo
  12. Add user to Virtual Postfix Database:
    • postmap virtual
  13. Reload Postfix:
    •  postfix reload
  14. Produces Postfix Queue List:
    •  postqueue -p
  15. Also Produces Postfix Queue List:
    • mailq
  16. Flush Postfix Queues:
    •  postqueue -f
  17. Remote Desktop for Windows (toggle -f on or off for fullscreen):
    • rdesktop -g 1152x768 -a 24 -b -f mail
  18. Unzip bz2 files:
    • bzip2 -cd files.tar.bz2 | tar xvf -
  19. Show program install path:
    • which {program}
  20. Removes mail from mail queue
    • postsuper -d {queue id}>
  21. Displays Hardware info from BIOS (must have installed dmidecode installed)
    • dmidecode
  22. To get a Network list of current IP/Hostname's, type the following on the command line:
    • dig axfr hosthame
  23. or to sort by IP type:
    • dig axfr hostname |grep IN | egrep A |sort -n  -k 5 -k 7 -t .
  24. Type the following to setup rpmq to find true kernel version
    • alias rpmq='rpm --qf '\''%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n'\'' -q'
  25. Type the following to determine the kernel version
    • rpmq kernel
  26. List all PCI Devices:
    • lspci
  27. Reload named:
    • rndc reload
  28. Create Database:
    • create database {DATABASE NAME};
  29. Create Database Privileges:
    • grant all privileges on {DATABASE NAME}.* to {DATABASE USER}@localhost identified by '{DATABASE PASSWORD}';
  30. Set Privileges:
    • flush privileges;
  31. Netstat IP,PORTS
    • netstat -tnap
  32. Create QEMU Disk Images:
    • qemu-img create -f qcow {name}.img 3G
  33. Install OS on QEMU Drive Image via CD-ROM
    • qemu -cdrom /dev/cdrom -hda {name}.img -m {memsize} -boot d
  34. Install OS on QEMU Drive Image via IMAGE
    • qemu -cdrom {name}.iso -hda {name}.img -m {memsize} -boot d
  35. Run QEMU Disk Images with Sound (Blaster16):
    • qemu -hda {name}.img -m {memsize} -soundhw es1370 -localtime
  36. Move seamless between host and guest
    • qemu -hda {name}.img -m {memsize} -soundhw es1370 -localtime -usb -usbdevice tablet
  37. Resize AVI Files (--export_asr 3 is widescreen and --export_asr 2 is fullscreen)
    • transcode -i INPUT.avi -y ffmpeg,ffmpeg -F mpeg4 -Z 320x,fast --export_asr 2 -o OUTPUT.avi -E 44100,16,2 -b 256
  38. Start NetworkManager GUI Applet
    • nm-applet &
  39. Set Password for MySQL Root
    • mysqladmin -u root password new-password
  40. Remove User account and Home dir
    • userdel -r {username}
  41. Mount an ISO image
    • mount -o loop -t iso9660 filename.iso /mnt/iso
  42. Create random passwords
    • head /dev/urandom | strings
  43. Show partions on a drive
    • sfdisk -l
  44. You want to download all the GIFs from an HTTP directory. The command 'wget http://host/dir/*.gif ' doesn't work, since HTTP retrieval does not support globbing. In that case, use:
    • wget -r -l1 --no-parent -A.gif http://host/dir/
  45. How to rsync

rsync -r -a -v -e "ssh -l {username}" --delete {remote machine}/dir /dir