Command
|
Description
|
#
rpm -ivh [package.rpm]
|
|
#
rpm -ivh --nodeeps [package.rpm]
|
|
#
rpm -U [package.rpm]
|
|
#
rpm -F [package.rpm]
|
|
#
rpm -e [package]
|
|
#
rpm -qa
|
|
#
rpm -qa | grep httpd
|
|
#
rpm -qi [package]
|
|
#
rpm -qg "System Environment/Daemons"
|
|
#
rpm -ql [package]
|
|
#
rpm -qc [package]
|
|
#
rpm -q [package] --whatrequires
|
|
#
rpm -q [package] --whatprovides
|
|
#
rpm -q [package] --scripts
|
|
#
rpm -q [package] --changelog
|
|
#
rpm -qf /etc/httpd/conf/httpd.conf
|
|
#
rpm -qp [package.rpm] -l
|
|
#
rpm --import /media/cdrom/RPM-GPG-KEY
|
|
#
rpm --checksig [package.rpm]
|
|
#
rpm -qa gpg-pubkey
|
|
#
rpm -V [package]
|
|
#
rpm -Va
|
|
#
rpm -Vp [package.rpm]
|
|
#
rpm -ivh /usr/src/redhat/RPMS/`arch`/[package.rpm]
|
|
|
|
#
rpm2cpio [package.rpm] | cpio --extract --make-directories *bin*
|
|
#
rpmbuild --rebuild [package.src.rpm]
|
|
#
dpkg -i [package.deb]
|
|
#
dpkg -r [package]
|
|
#
dpkg -l
|
|
#
dpkg -l | grep httpd
|
|
#
dpkg -s [package]
|
|
#
dpkg -L [package]
|
|
#
dpkg --contents [package.deb]
|
|
#
dpkg -S /bin/ping
|
|
#
cat file1
|
|
#
head -2 file1
|
|
#
less file1
|
similar
to 'more' command but which allows backward movement in the file
as well as forward movement [man]
|
#
more file1
|
|
#
tac file1
|
|
#
tail -2 file1
|
|
#
tail -f /var/log/messages
|
#
cat example.txt | awk 'NR%2==1'
|
||
#
echo a b c | awk '{print $1}'
|
||
#
echo a b c | awk '{print $1,$3}'
|
||
#
cat -n file1
|
||
#
comm -1 file1 file2
|
||
#
comm -2 file1 file2
|
||
#
comm -3 file1 file2
|
||
#
diff file1 file2
|
||
#
grep Aug /var/log/messages
|
||
#
grep ^Aug /var/log/messages
|
||
#
grep [0-9] /var/log/messages
|
||
#
grep Aug -R /var/log/*
|
||
#
paste file1 file2
|
||
#
paste -d '+' file1 file2
|
||
#
sdiff file1 file2
|
||
#
sed 's/string1/string2/g' example.txt
|
||
#
sed '/^$/d' example.txt
|
||
#
sed '/ *#/d; /^$/d' example.txt
|
||
#
sed -e '1d' exampe.txt
|
||
#
sed -n '/string1/p'
|
||
#
sed -e 's/ *$//' example.txt
|
||
#
sed -e 's/string1//g' example.txt
|
||
#
sed -n '1,5p' example.txt
|
||
#
sed -n '5p;5q' example.txt
|
||
#
sed -e 's/00*/0/g' example.txt
|
||
#
sort file1 file2
|
||
|
|
|
#
sort file1 file2 | uniq
|
|
|
|
||
#
sort file1 file2 | uniq -u
|
|
|
#
sort file1 file2 | uniq -d
|
||
#
echo 'word' | tr '[:lower:]' '[:upper:]'
|
||
|
#
dos2unix filedos.txt fileunix.txt
|
|
#
recode ..HTML < page.txt > page.html
|
|
#
recode -l | more
|
|
#
unix2dos fileunix.txt filedos.txt
|
#
badblocks -v /dev/hda1
|
|
#
dosfsck /dev/hda1
|
|
#
e2fsck /dev/hda1
|
|
#
e2fsck -j /dev/hda1
|
|
#
fsck /dev/hda1
|
|
#
fsck.ext2 /dev/hda1
|
|
#
fsck.ext3 /dev/hda1
|
|
#
fsck.vfat /dev/hda1
|
|
#
fsck.msdos /dev/hda1
|
#
fdformat -n /dev/fd0
|
|
#
mke2fs /dev/hda1
|
|
#
mke2fs -j /dev/hda1
|
|
#
mkfs /dev/hda1
|
|
#
mkfs -t vfat 32 -F /dev/hda1
|
|
#
mkswap /dev/hda3
|
#
mkswap /dev/hda3
|
|
#
swapon /dev/hda3
|
|
#
swapon /dev/hda2 /dev/hdb3
|
#
find /var/log -name '*.log' | tar cv --files-from=- | bzip2 >
log.tar.bz2
|
|
#
find /home/user1 -name '*.txt' | xargs cp -av
--target-directory=/home/backup/ --parents
|
|
#
dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz'
|
|
#
dd if=/dev/sda of=/tmp/file1
|
|
#
dd if=/dev/hda of=/dev/fd0 bs=512 count=1
|
|
#
dd if=/dev/fd0 of=/dev/hda bs=512 count=1
|
|
#
dump -0aj -f /tmp/home0.bak /home
|
|
#
dump -1aj -f /tmp/home0.bak /home
|
|
#
restore -if /tmp/home0.bak
|
|
#
rsync -rogpav --delete /home /tmp
|
|
#
rsync -rogpav -e ssh --delete /home ip_address:/tmp
|
|
#
rsync -az -e ssh --delete ip_addr:/home/public /home/local
|
|
#
rsync -az -e ssh --delete /home/local ip_addr:/home/public
|
|
#
tar -Puf backup.tar /home/user
|
|
#
( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr 'cd
/home/share/ && tar x -p'
|
|
#
( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home &&
tar x -p'
|
|
#
tar cf - . | (cd /tmp/backup ; tar xf - )
|
#
cd-paranoia -B
|
|
#
cd-paranoia --
|
|
#
cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force
|
|
#
cdrecord -v dev=/dev/cdrom cd.iso
|
|
#
gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom -
|
|
#
cdrecord --scanbus
|
|
#
dd if=/dev/hdc | md5sum
|
|
#
mkisofs /dev/cdrom > cd.iso
|
|
#
mkisofs /dev/cdrom | gzip > cd_iso.gz
|
|
#
mkisofs -J -allow-leading-dots -R -V
|
|
#
mount -o loop cd.iso /mnt/iso
|
#
dhclient eth0
|
|
#
ethtool eth0
|
|
#
host www.example.com
|
|
#
hostname
|
|
#
ifconfig eth0
|
|
#
ifconfig eth0 192.168.1.1 netmask 255.255.255.0
|
|
#
ifconfig eth0 promisc
|
|
#
ifdown eth0
|
|
#
ifup eth0
|
|
#
ip link show
|
|
#
iwconfig eth1
|
|
#
iwlist scan
|
|
#
mii-tool eth0
|
|
#
netstat -tup
|
|
#
netstat -tupl
|
|
#
netstat -rn
|
|
#
nslookup www.example.com
|
|
#
route -n
|
|
#
route add -net 0/0 gw IP_Gateway
|
|
#
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1
|
|
#
route del 0/0 gw IP_gateway
|
|
#
echo "1" > /proc/sys/net/ipv4/ip_forward
|
|
#
tcpdump tcp port 80
|
|
#
whois www.example.com
|
#
mount -t smbfs -o username=user,password=pass //WinClient/share
/mnt/share
|
|
#
nbtscan ip_addr
|
|
#
nmblookup -A ip_addr
|
|
#
smbclient -L ip_addr/hostname
|
|
#
smbget -Rr smb://ip_addr/share
|
#
iptables -t filter -L
|
|
#
iptables -t nat -L
|
|
#
iptables -t filter -F
|
|
#
iptables -t nat -F
|
|
#
iptables -t filter -X
|
|
#
iptables -t filter -A INPUT -p tcp --dport telnet -j ACCEPT
|
|
#
iptables -t filter -A OUTPUT -p tcp --dport http -j DROP
|
|
#
iptables -t filter -A FORWARD -p tcp --dport pop3 -j ACCEPT
|
|
#
iptables -t filter -A INPUT -j LOG --log-prefix
|
|
#
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
#
iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp -m tcp --dport
22 -j DNAT --to-destination 10.0.0.2:22
|
|
#
alias hh='history'
|
|
#
apropos ...keyword
|
display
a list of commands that pertain to keywords of a program , useful
when you know what your program does, but you don't know the name
of the command [man]
|
#
chsh
|
|
#
chsh --list-shells
|
|
#
gpg -c file1
|
|
#
gpg file1.gpg
|
|
#
ldd /usr/bin/ssh
|
|
#
man ping
|
display
the on-line manual pages for example on ping command - use '-k'
option to find any related commands [man]
|
#
mkbootdisk --device /dev/fd0 `uname -r`
|
|
#
wget -r www.example.com
|
|
#
wget -c www.example.com/file.iso
|
|
#
echo 'wget -c www.example.com/files.iso' | at 09:00
|
|
#
whatis ...keyword
|
|
#
who -a
|
show
who is logged on, and print: time of last system boot, dead
processes, system login processes, active processes spawned by
init, current runlevel, last system clock change [man]
|
#
pacman -S name
|
|
#
pacman -R name
|
Syntax
|
Description
|
Example(s)
|
rpm
-ivh {rpm-file}
|
Install
the package
|
rpm
-ivh mozilla-mail-1.7.5-17.i586.rpm
rpm -ivh --test mozilla-mail-1.7.5-17.i586.rpm |
rpm
-Uvh {rpm-file}
|
Upgrade
package
|
rpm
-Uvh mozilla-mail-1.7.6-12.i586.rpm
rpm -Uvh --test mozilla-mail-1.7.6-12.i586.rpm |
rpm
-ev {package}
|
Erase/remove/
an installed package
|
rpm
-ev mozilla-mail
|
rpm
-ev --nodeps {package}
|
Erase/remove/
an installed package without checking for dependencies
|
rpm
-ev --nodeps mozilla-mail
|
rpm
-qa
|
Display
list all installed packages
|
rpm
-qa
rpm -qa | less |
rpm
-qi {package}
|
Display
installed information along with package version and short
description
|
rpm
-qi mozilla-mail
|
rpm
-qf {/path/to/file}
|
Find
out what package a file belongs to i.e. find what package owns the
file
|
rpm
-qf /etc/passwd
rpm -qf /bin/bash |
rpm
-qc {pacakge-name}
|
Display
list of configuration file(s) for a package
|
rpm
-qc httpd
|
rpm
-qcf {/path/to/file}
|
Display
list of configuration files for a command
|
rpm
-qcf /usr/X11R6/bin/xeyes
|
rpm
-qa --last
|
Display
list of all recently installed RPMs
|
rpm
-qa --last
rpm -qa --last | less |
rpm
-qpR {.rpm-file}
rpm -qR {package} |
Find
out what dependencies a rpm file has
|
rpm
-qpR mediawiki-1.4rc1-4.i586.rpm
rpm -qR bash |
Linux Add a Swap File – Howto
Ineed
additional swap space to improve my system performance. How do I add
a swap file to Linux system using command line options?
In Linux, as in most other Unix-like operating systems, it is common to use a whole partition of a hard disk for swapping. However, with the 2.6 Linux kernel, swap files are just as fast as swap partitions, although I recommends using a swap partition. The administrative flexibility of swap files outweighs that of partitions; since modern high capacity hard drives can remap physical sectors, no partition is guaranteed to be contiguous. You can add swap file as a dedicated partition or use following instructions to create a swap file.
In Linux, as in most other Unix-like operating systems, it is common to use a whole partition of a hard disk for swapping. However, with the 2.6 Linux kernel, swap files are just as fast as swap partitions, although I recommends using a swap partition. The administrative flexibility of swap files outweighs that of partitions; since modern high capacity hard drives can remap physical sectors, no partition is guaranteed to be contiguous. You can add swap file as a dedicated partition or use following instructions to create a swap file.
Procedure To Add a Swap File Under Linux
You need to use
the dd command to create swap file. The mkswap command is used to set
up a Linux swap area on a device or in a file.
Step #1: Login as the Root User
Open a terminal
window (select Applications > Accessories > Terminal) or login
to remote server using the ssh client. Switch to the root user by
typing su - and entering the root password, when prompted
Step #2: Create Storage File
Type the
following command to create 512MB swap file (1024 * 512MB = 524288
block size):#
dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
Where,
Where,
- if=/dev/zero : Read from /dev/zero file. /dev/zero is a special file in that provides as many null characters to build storage file called /swapfile1.
- of=/swapfile1 : Read from /dev/zero write stoage file to /swapfile1.
- bs=1024 : Read and write 1024 BYTES bytes at a time.
- count=524288 : Copy only 523288 BLOCKS input blocks.
Step #3: Set Up a Linux Swap Area
Type the
following command to set up a Linux swap area in a file:#
mkswap /swapfile1
Setup correct file permission for security reasons, enter:# chown root:root /swapfile1
# chmod 0600 /swapfile1
A world-readable swap file is a huge local vulnerability. The above command make sure only root user can read/write to the file. Finally, activate /swapfile1 swap space immediately, enter:# swapon /swapfile1
Setup correct file permission for security reasons, enter:# chown root:root /swapfile1
# chmod 0600 /swapfile1
A world-readable swap file is a huge local vulnerability. The above command make sure only root user can read/write to the file. Finally, activate /swapfile1 swap space immediately, enter:# swapon /swapfile1
To activate
/swapfile1 after Linux system reboot, add entry to /etc/fstab file.
Open this file using a text editor such as vi:#
vi /etc/fstab
Append the
following line:/swapfile1
swap swap defaults 0 0
Save and close the file. Next time Linux comes up after reboot, it enables the new swap file for you automatically.
Save and close the file. Next time Linux comes up after reboot, it enables the new swap file for you automatically.
How do I Verify Swap is Activated or Not?
Simply use the
free command:$
free -m
No comments:
Post a Comment