Submitted by Dirk on 1 November, 2007 - 21:48
Sprache
Undefined
lsof /bin/bash
lists all processes that use the bash shell
lsof -p PID
lists all open files of the process with the given PID
lsof +D /tmp
lists all open files in "/tmp" and its subdirectories without paying attention to symbolic links
lsof -u user
lists all files that are opened by the given user
lsof -u ^user
lists all opened files that are not opened by the given user
lsof -d txt
process list a la ps aux
lsof +L1
lists all deleted files, that are still opened and use up disk space (files with less than one link)
lsof -i
network-relevant files
lsof -i -P -n
all network-relevant files without spelling out the port numbers as services and without resolving the hostname
lsof -i6
ipv6-related files
lsof -i|grep '\->'
lists all active connections
lsof -a -i -u www-data
lists all network files opened by the user www-data (boolean and with -a)
Submitted by Dirk on 7 June, 2007 - 17:31
Sprache
Undefined
This will limit incoming connections to port 22 to no more than 4 attemps in ten minutes. Any more will be dropped.
You can adjust the numbers yourself to limit connections further.
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 600 --hitcount 4 -j DROP
(Found here http://blog.blackdown.de/2005/02/18/mitigating-ssh-brute-force-attacks-with-ipt_recent/
Submitted by Dirk on 2 June, 2007 - 11:31
Sprache
Undefined
cd /tmp
tar cvf - blarg | (cd /var; tar xf -)
or to copy from a local machine to a remote machine
tar Pcfz - /usr/local/src/aolserver | ssh rumborak.foobar.de tar Pvxfz -
or to copy from a remote machine to a local machine
ssh rumborak.foobar.de tar Pcfz - /usr/local/src/aolserver | tar Pvxfz -
Submitted by Dirk on 2 June, 2007 - 11:29
Sprache
Undefined
Find out the version number of an installed package
rpm -q Blahblah
Get a list of all installed packages
rpm -qa
Find out to which package a file belongs
rpm -qf /home/dirk/bla.ttx
Display information about the specified package:
rpm -qi rpm
Show the files that will be installed for the specified package file:
rpm -qp1 bla.rpm
Listing the files in a package file
rpm2cpio logrotate-1.0-1.i386.rpm | cpio -t
Submitted by Dirk on 2 June, 2007 - 11:27
Sprache
Undefined
sed '23!d' filename
Output line 23 of filename
sed '23,42!d' filename
Output lines 23 to 42 of filename
sed -n '/foo/,/bar/p' filename
Output all lines between the first line that matches foo and the last line
that matches bar.
sed -n '/foo/,/bar/p' filename
Output all lines that are not in between the lines which contain "foo" and "bar"
Submitted by Dirk on 2 June, 2007 - 11:22
Sprache
Undefined
grep '^..$' filename
Match all lines with exactly two characters
grep '^.\{12\}$' filename
Match all lines with exactly 12 characters
grep '^.\{12,\}$' filename
Match all lines with at least 12 characters
grep '^.\{7,12\}$' filename
Match all lines with at least 7 and less than or equal to 12 characters
grep -v foobar filename
Match all lines in filename that do not match foobar
Submitted by Dirk on 2 June, 2007 - 11:19
Sprache
Undefined
find . -name Root -exec perl -pi -e 's/\/usr\/local\/cvsroot/\/cvsweb/' {} \; find .
Submitted by Dirk on 2 June, 2007 - 11:16
Sprache
Undefined
apt
apt-cache add apt-cache gencaches apt-cache showpkg apt-cache stats apt-cache unmet apt-cache search apt-cache depends apt-cache policy apt-cache pkgnames apt-cache dotty
dpgk
dpkg -l List packages matching given pattern. If no package-name-pattern is given, list all packages in /var/lib/dpkg/available. dpkg -L List files installed to your system from package. dpkg -S Search for a filename from installed packages
dselect
+ Install or upgrade - Remove _ Remove and purge config = Hold in present state : Unhold: upgrade or leave uninstalled o Change order of the list v,V Toggle verbose display i,I Toggle/cycle info displays U set all to sUggested state D set all to Directly requested state / search (Return to cancel) \ repeat last search