Catch all traffic between the hosts host1.example.org and host2.example.org on all interfaces and dump the traffic to the file dump2.raw
tcpdump host host1.example.org and host2.example.org -i any -w dump2.raw
Catch all traffic between the hosts host1.example.org and host2.example.org on all interfaces and dump the traffic to the file dump2.raw
tcpdump host host1.example.org and host2.example.org -i any -w dump2.raw
compress tar
tar cvf mytar.tar .
extract tar
tar xvf mytar.tar
Only show the contents of tar archive:
tar tvf mytar.tar
Install a given rpm package. –force overwrites the package if it is already installed
rpm -i --force myrpm.rpm
List installed rpm packages (-qa: query all)
rpm -qa
Find the exact name of an installed rpm package
rpm -qa | grep java
Uninstall the Java package in one step by using a subcommand.
rpm -e `rpm -qa | grep $PKG`
uninstall package without using scripts. This is useful if the package won’t uninstall when trying to uninstall it normally. Afterwards the package is not listed anymore by rpm -qa
rpm -e mypackage --noscripts
Copy a directory from localhost to a remote directory on a remote machine:
scp -r mydir username@remotemachine:/home/remotedirectory/
Copy a remote directory from a remote machine to the current directory:
scp -r username@remotemachine:/home/remotedirectory/ .
username is the user on remote host
remotemachine is the remote machine’s name or IP
remote directory is specified after the colon
/usr/sbin/userdel myuser /usr/sbin/groupdel mygroup
command > file 2>&1
ex.:
ps -e > log.txt 2>&1
If you edit files under Windows and then move them to a Linux server, you may encounter the problem that Windows uses \r\n as newline while Linux just uses \n. To remove the carriage return in all files ending on .sh or .SPEC use the following command:
find . -type f \( -name "*.sh" -o -name "*.SPEC" \) -exec sh -c "tr -d '\15\32' {} > {}.nn" \;
For each file found by find, a shell is executed, which again executes the tr command to drop \r. The tr command is given the current file via the {} parameter. The output of the tr command is redirected from the standard output to a new file that consists of the current file’s name ({} again} plus the ending .nn.
Remove the file ending .nn in this directory and all subdirectories:
rename .nn "" **/*.nn
rpm2cpio my_pkg.rpm | cpio -dimv