Linux Commands
Revision as of 21:33, 15 August 2014 by 142.90.148.3 (talk)
- RPM Version Info:
- rpm -qa foo 
 
- Shutdown X11:
- init 3 
 
- Reboot the System:
- init 6 
 
- Mount a CDROM:
- mount /dev/cdrom 
 
- Unmount a CDROM:
- umount /dev/cdrom 
 
- List Start Up Scripts:
- chkconfig --list 
 
- Turn On Start Up Script:
- chkconfig service start 
 
- Turn Off Start Up Script:
- chkconfig service off 
 
- Get the kernel version by typing
- uname -r 
 
- Format USB Device to Vfat
- mkfs.vfat -F 32 /dev/sda1 
 
- How to create tarball's assuming your directory is called foo:</pre>
- tar -cvzf foo.tar.gz /dir/foo 
 
- Add user to Virtual Postfix Database:</pre>
- postmap virtual 
 
- Enable RAID1 Mirroring ndas:
- ndasadmin enable -s 1 -o w 2 
 
- Reload Postfix:
- postfix reload 
 
- Produces Postfix Queue List:
- postqueue -p 
 
- Also Produces Postfix Queue List:
- mailq 
 
- Flush Postfix Queues:
- postqueue -f 
 
- Remote Desktop for Windows (toggle -f on or off for fullscreen):
- rdesktop -g 1152x768 -a 24 -b -f mail 
 
- Unzip bz2 files:
- bzip2 -cd files.tar.bz2 | tar xvf - 
 
- Show program install path:
- which {program}
 
- Removes mail from mail queue
- postsuper -d {queue id}>
 
- Displays Hardware info from BIOS (must have installed dmidecode installed)
- dmidecode 
 
- To get a Network list of current IP/Hostname's, type the following on the command line:
- dig axfr hosthame 
 
- or to sort by IP type:
- dig axfr hostname |grep IN | egrep A |sort -n -k 5 -k 7 -t . 
 
- Type the following to setup rpmq to find true kernel version
- alias rpmq='rpm --qf '\''%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n'\'' -q'
 
- Type the following to determine the kernel version
- rpmq kernel 
 
- List all PCI Devices:
- lspci 
 
- Reload named:
- rndc reload 
 
- Create Database:
- create database {DATABASE NAME};
 
- Create Database Privileges:
- grant all privileges on {DATABASE NAME}.* to {DATABASE USER}@localhost identified by '{DATABASE PASSWORD}';
 
- Set Privileges:
- flush privileges; 
 
- Netstat IP,PORTS
- netstat -tnap 
 
- Create QEMU Disk Images:
- qemu-img create -f qcow {name}.img 3G
 
- Install OS on QEMU Drive Image via CD-ROM
- qemu -cdrom /dev/cdrom -hda {name}.img -m {memsize} -boot d
 
- Install OS on QEMU Drive Image via IMAGE
- qemu -cdrom {name}.iso -hda {name}.img -m {memsize} -boot d
 
- Run QEMU Disk Images with Sound (Blaster16):
- qemu -hda {name}.img -m {memsize} -soundhw es1370 -localtime
 
- Move seamless between host and guest
- qemu -hda {name}.img -m {memsize} -soundhw es1370 -localtime -usb -usbdevice tablet
 
- 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 
 
- Start NetworkManager GUI Applet
- nm-applet & 
 
- Set Password for MySQL Root
- mysqladmin -u root password new-password 
 
- Remove User account and Home dir
- userdel -r {username}
 
- Mount an ISO image
- mount -o loop -t iso9660 filename.iso /mnt/iso 
 
- Create random passwords
- head /dev/urandom | strings 
 
- Show partions on a drive
- sfdisk -l 
 
-  You want to download all the GIFs from an HTTP directory. The command doesn't work since HTTP retrieval does not support globbing. In that case, use:
- wget -r -l1 --no-parent -A.gif http://host/dir/ 
 
-  How to rsync
- rsync -r -a -v -e "ssh -l {username}" --delete {remote machine}:/dir /dir
 
-  How to check memory
- ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd -ww --sort=pid 
 
-  How to search and replace recursively within files
- find . -type f -exec sed -i s/search/replace/g {} +
 
-  How to convert Flac to MP3
- for file in *.flac; do flac -cd "$file" | lame -h - "${file%.flac}.mp3"; done
 
-  How to check 3ware Hardware RAID status:
- tw_cli /c0 show 
 
-  Dirvish Vault first init
- dirvish -vault ''vaultname'' --init 
 
-  CIFS mount:
- mount -o username=username,password=1234,uid=username,gid=groupname,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm //host/disk /mnt/NAS/ 
 
-  How to install all development tools:
- yum groups install "Development Tools 
- apt-get install build-essential 
 
-  How to enable ndadmin slot:
- ndasadmin enable -s 1 -o w 
 
-  How to install Debian Kernel headers:
- apt-get install linux-headers-$(uname -r) 
 
-  How to find the largest file/directory human readable from your current directory:
- du -hsx * | sort -rh | head -10 
 
-  How to list all installed PERL modules:
- perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC'
 
-  GLOBAL REPLACE in the files (change call to mall in all *.kumac files):
- awk '{gsub("call", "mall", $0); print > FILENAME}' *.kumac
 
-  The fastest way to scan all your computers/network subnet for open ports ever:
- nmap -T5 192.168.1.0/24 
 
