Post by ZF on Aug 11, 2009 22:00:43 GMT -5
/********** How to use vi **********/
type i to edit
type / and word u wanna find
esc and :q to quit
esc and :wq to save and quit
vi .bash_profile //save path at startup
alt f7 //move terminal around
ctrl shift C //copy
ctrl shift n //new terminal
./ //run exe
source //run .sh script files
which //check version
rm -rf //remove directories
ctrl + alt + arrow //shift between workspaces
ctrl + alt + shift //shift app between workspaces
/**********How to use RPM***********/
//show all rpm installed
rpm -qa
//Installing rpm messages
rpm -i <package name>
//if installation fail, use the explorer and double click
//removing
rpm -e <package name w/o .rpm>
//printout rpm content
rpm2cpio <filename>.rpm | cpio -t
//To extract all files from an RPM:
rpm2cpio RPM_file | cpio -idv
//Installing for different architecture
rpm -Uvh --ignorearch stlinux20-sh4-busybox-1.00-9.sh4.rpm
/*************** Misc LINUX Commands ************/
chmod +x filename //makes file exe
grep -r keywords //search all the files for the keyword specified
For ftp
type mget *
and u can select all files to get
To create patch file :
diff -c filename.original filename.amended > patchfilename
To patch :
patch -p0 < patchfilename
-pX where X is the argument in the path to remove.
Its better to use --dryrun to check if there is any conflicts
patch -p0 --dryrun < patchfilename
//To create patch recursively
diff -uprN olddir newdir > new-patch
u = unified format
p = show nearest function name
N = include new / deleted file
r = recursive
//Recursively grep
grep -r "somestring" *
//Recursively grep and list file instead of content
grep -rl "something" *
find . -name <filename>
route to get gateway ip.
To check processes priority:
ps -eLF
ps -eLo ppid,pid,pgid,lwp,priority,cmd
//For hashing
makemap hash access.db < access
//To check CPU usage
top -d 0.5
//How to use sed to replace multiple file text string in Linux
grep -rl OLDSTRING * | xargs sed -i -e 's/OLDSTRING/NEWSTRING/'
NOTE!!! its ' and not `
e.g To remove optimization and include debug
grep -rl "\-O\$(OPTLEVEL)" * | xargs sed -i -e 's/\-O\$(OPTLEVEL)/\-g/'
//Zipping with password
zip -er zipfile.zip *
//How to set date
date -s YYYYMMDD
//To set default gateway
route add -net default gw 10.80.115.254 dev eth0
TO see all devices and path
udevinfo -e
//Query all attributes relating to a device path
udevinfo -a -p /block/sda/sda1
//To get "/block/sda/sda1"
udevinfo -q path -n /dev/sda
udevinfo -a -p $(udevinfo -q path -n /dev/sda)
//To check size of directory
du -h | grep -v '/' | awk '{print $1}'
//ssh copy command
scp filename <targetip>:/
//Mounting ntfs files
mount -t ntfs-3g /dev/sdb1 temp -o force
//To clean out a kernel completely, use
make mrproper
strace <executable> to reverse engineer binary
Use nm to check if function has been compiled; Alt to typing rubbish into c code to see if it can compile
Searching through your history: If you hit ^R (Ctrl+R) then start typing, bash will display the last match from your command history. Hit enter to execute the displayed command, left or right arrow to edit the command, or ^C to cancel.
Use ^Z to run a program in the background
Type fg to bring the program back to front
Useful Aliases
alias rm="rm -i"
alias cp="cp -i"
alias mv="mv -i"
#Automatically do an ls after each cd
cd() {
builtin cd "$@" && ls
}
#Print ipaddress
MY_IP=`/sbin/ifconfig eth0 | grep inet | grep -v inet6 | cut -d: -f2 |awk '{ print $1}'`
echo "IP ADDRESS = "$MY_IP
echo ""
type i to edit
type / and word u wanna find
esc and :q to quit
esc and :wq to save and quit
vi .bash_profile //save path at startup
alt f7 //move terminal around
ctrl shift C //copy
ctrl shift n //new terminal
./ //run exe
source //run .sh script files
which //check version
rm -rf //remove directories
ctrl + alt + arrow //shift between workspaces
ctrl + alt + shift //shift app between workspaces
/**********How to use RPM***********/
//show all rpm installed
rpm -qa
//Installing rpm messages
rpm -i <package name>
//if installation fail, use the explorer and double click
//removing
rpm -e <package name w/o .rpm>
//printout rpm content
rpm2cpio <filename>.rpm | cpio -t
//To extract all files from an RPM:
rpm2cpio RPM_file | cpio -idv
//Installing for different architecture
rpm -Uvh --ignorearch stlinux20-sh4-busybox-1.00-9.sh4.rpm
/*************** Misc LINUX Commands ************/
chmod +x filename //makes file exe
grep -r keywords //search all the files for the keyword specified
For ftp
type mget *
and u can select all files to get
To create patch file :
diff -c filename.original filename.amended > patchfilename
To patch :
patch -p0 < patchfilename
-pX where X is the argument in the path to remove.
Its better to use --dryrun to check if there is any conflicts
patch -p0 --dryrun < patchfilename
//To create patch recursively
diff -uprN olddir newdir > new-patch
u = unified format
p = show nearest function name
N = include new / deleted file
r = recursive
//Recursively grep
grep -r "somestring" *
//Recursively grep and list file instead of content
grep -rl "something" *
find . -name <filename>
route to get gateway ip.
To check processes priority:
ps -eLF
ps -eLo ppid,pid,pgid,lwp,priority,cmd
//For hashing
makemap hash access.db < access
//To check CPU usage
top -d 0.5
//How to use sed to replace multiple file text string in Linux
grep -rl OLDSTRING * | xargs sed -i -e 's/OLDSTRING/NEWSTRING/'
NOTE!!! its ' and not `
e.g To remove optimization and include debug
grep -rl "\-O\$(OPTLEVEL)" * | xargs sed -i -e 's/\-O\$(OPTLEVEL)/\-g/'
//Zipping with password
zip -er zipfile.zip *
//How to set date
date -s YYYYMMDD
//To set default gateway
route add -net default gw 10.80.115.254 dev eth0
TO see all devices and path
udevinfo -e
//Query all attributes relating to a device path
udevinfo -a -p /block/sda/sda1
//To get "/block/sda/sda1"
udevinfo -q path -n /dev/sda
udevinfo -a -p $(udevinfo -q path -n /dev/sda)
//To check size of directory
du -h | grep -v '/' | awk '{print $1}'
//ssh copy command
scp filename <targetip>:/
//Mounting ntfs files
mount -t ntfs-3g /dev/sdb1 temp -o force
//To clean out a kernel completely, use
make mrproper
strace <executable> to reverse engineer binary
Use nm to check if function has been compiled; Alt to typing rubbish into c code to see if it can compile
Searching through your history: If you hit ^R (Ctrl+R) then start typing, bash will display the last match from your command history. Hit enter to execute the displayed command, left or right arrow to edit the command, or ^C to cancel.
Use ^Z to run a program in the background
Type fg to bring the program back to front
Useful Aliases
alias rm="rm -i"
alias cp="cp -i"
alias mv="mv -i"
#Automatically do an ls after each cd
cd() {
builtin cd "$@" && ls
}
#Print ipaddress
MY_IP=`/sbin/ifconfig eth0 | grep inet | grep -v inet6 | cut -d: -f2 |awk '{ print $1}'`
echo "IP ADDRESS = "$MY_IP
echo ""