Archive for March, 2010
Linux lethal commands
In this post I will collect all commands which SHOULD NEVER be executed in Linux. Any of them will cause data loss or corruption, can freeze or hang up running system.
NEVER RUN THESE COMMANDS IN LINUX BOX CLI!
Even if somebody advises you in forum/im to do it.
1. Any of these commands will erase [...]
Using RPM and dpkg
The /bin/rpm program on Red Hat and derivitives and the /usr/bin/dpkg on
Debian and derivitives are used to control the management of packages.
• Remove a package
# rpm -e <package-name>
# dpkg -r <package-name>
• List contents of entire package
# rpm -qvl <package-name.rpm>
# dpkg -c <package-name.deb>
• List all installed packages with info about each
# rpm -qvia
# dpkg -l
• List [...]
TCPDUMP
Command Line Options
-A Print frame payload in ASCII
-c <count> Exit after capturing count packets
-D List available interfaces
-e Print link-level headers
-F <file> Use file as the filter expression
-G <n> Rotate the dump file every n seconds
-i <iface> Specifies the capture interface
-K Don’t verify TCP checksums
-L List data link types for the interface
-n Don’t convert addresses to [...]
important mysql command, backup, dump restore
Connest to mysql server
mysql -u USERNAME -h ‘HOST_IP’ -p
enter password – here
mysql> show databases;
mysql> use DATABASE_NAME;
mysql> your query here.
Dumping a mySQL to a sql file
mysqldump -l –opt databasename > /root/file/location/filename.sql -u user –password=whateverthepass
Importing mySQL dump file
mysql databasename < /root/file/location/filename.sql -u user –password=whateverthepass
Copying Entire Folder of Files
cp – Ru /root/file/location/* /where/it/should/go –reply=yes
Making a [...]
Printing linux commands
/etc/rc.d/init.d/lpd start Start the print daemon
/etc/rc.d/init.d/lpd stop Stop the print daemon
/etc/rc.d/init.d/lpd
status
Display status of the print daemon
lpq Display jobs in print queue
lprm Remove jobs from queue
lpr Print a file
lpc Printer control tool
man subject | lpr Print the manual page called subject
as plain text
man -t subject | lpr Print the manual page called subject
as Postscript output
printtool Start [...]
Configuration files and what they do
/etc/profile System wide environment variables for
all users.
/etc/fstab List of devices and their associated mount
points. Edit this file to add cdroms, DOS
partitions and floppy drives at startup.
/etc/motd Message of the day broadcast to all users
at login.
etc/rc.d/rc.local Bash script that is executed at the end of
login process. Similar to autoexec.bat in
DOS.
/etc/HOSTNAME Conatins full hostname including domain.
/etc/cron.* There [...]
Installing software for Linux
rpm -ihv name.rpm Install the rpm package called name
rpm -Uhv name.rpm Upgrade the rpm package called
name
rpm -e package Delete the rpm package called
package
rpm -l package List the files in the package called
package
rpm -ql package List the files and state the installed
version of the package called
package
rpm -i –force package Reinstall the rpm package called
name having deleted [...]
Accessing & mounting file systems
mount -t iso9660 /dev/cdrom
/mnt/cdrom
Mount the device cdrom
and call it cdrom under the
/mnt directory
mount -t msdos /dev/hdd
/mnt/ddrive
Mount hard disk “d” as a
msdos file system and call
it ddrive under the /mnt
directory
mount -t vfat /dev/hda1
/mnt/cdrive
Mount hard disk “a” as a
VFAT file system and call it
cdrive under the /mnt
directory
umount /mnt/cdrom Unmount the cdrom
Linux machine Starting, Stopping and restart
shutdown -h now Shutdown the system now and do not
reboot
halt Stop all processes – same as above
shutdown -r 5 Shutdown the system in 5 minutes and
reboot
shutdown -r now Shutdown the system now and reboot
shutdown -r -F now Force fsck on reboot.
shutdown -r -f now skip fsck on reboot.
reboot Stop all processes and then reboot – [...]
Replace word from multiple files in linux/unix using grep and perl
for single file.
perl -pi -e ’s/OLDCHAR/NEWCHAR/g’ filename.txt
For multiple files.
grep -R –files-with-matches ‘OLDCHAR’ . | sort | uniq | xargs perl -pi~ -e ’s/OLDCHAR/NEWCHAR/g’
Thanks,
Jayesh
