Tips, Tricks, and Info!
| Lennart Andersen | Linux | Debian | Suse | Networking | OSX | Windows | Links | Top Virus / Security Issues |
If you like to have something added to this page please fill out the form and I will add it! Contact Me
| BASH HOTKEYS |
|
| My favourite common alias links |
|
| find biggest subdirect. | du -kx | egrep -v "\./.+/" | sort -n |
| pre-fix common typos | alias ls-l="ls -l ";alias ll="ls -l" |
| extract columns | cut -c 8-15 file1 > file2 |
| text replace in file | sed "s/word1/word2/g" file1 > file2 |
| del whitespace lines | sed '/^\s*$/d' tst.htm > tst2.htm |
| multi file text replace |
|
| Search all regular files for 'example' in this dir and below | find -type f -print0 | xargs -r0 grep -F 'example' |
| Find command that highlight the data you are looking for | find server.log -type f -print0 | xargs -0 grep -i -n -I --max-count=50 --color=always DATA |
| To find out the large files on a file system. | find / -xdev -size +1024 -exec ls -al {} \; | sort -r -k 5 |
| To find and remove core files conditionally | find ~ -name core -exec file {} \; -exec rm -i {} \; (the "-i" will ask you to say yes to remover the core file, safety first) |
| List files by date. | ls -ltr |
| Find hidden files | ls -a | grep "^\." |
| Monitor messages in a log file | tail -f /var/log/messages |
| List paths that process id has open | lsof -p $$ |
| List processes in a hierarchy | ps -e -o pid,args --forest |
| List processes by % cpu usage | ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d' |
| Display selected user with top | top -u geek |
| List only specific process with top | top -p 1390, 3656 |
| List all packages by installed size (Bytes) on rpm distros | rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n |
| Watch changeable data continuously | watch -n 1 'cat /proc/interrupts' |
| LOOK FOR A STRING | grep "hello world" `find ./ -name "*" -print -exec file {} \; | grep text | cut -d ':' -f 1` |
| Kill a User, the linux/unix way | kill -9 `ps -aef|grep "USER" |awk '{ print $2 }'` |
| RENICE CPU HOGS | renice 20 `ps aux | sort -rn +3 -4 | head -1 | awk '{print $2}'` |
| Replace string1 with string2 | sed 's/string1/string2/g' |
| To find pci devices use! With detailed information | lspci -v |
| Mount an ISO file linux | mount -t iso9660 -o loop /home/user/file.iso /mnt/iso |
| Security from users with big thumbs. | touch -i ( in any directory that you would like to protect from"rm" If rm is run it would be with the -i option. |
| Create an ISO disk image from a CD-ROM (sr0 being the cdrom) | dd if=/dev/sr0 of=linux.iso bs=2048 conv=noerror,sync |
| apt-get update / apt-get upgrade | First update the package lists / Then upgrade the packages |
| apt-get install vim vim-runtime | Install the full package vim and vim-runtime |
| dpkg --remove vim | Remove the package vim |
| dpkg -l | List installed packages, Debian/Ubuntu |
| update-rc.d rc.local defaults | Activate rc.local with the default runlevels |
| update-rc.d -f rc.local remove | Removes the rc.local from all runlevels |
| zypper refresh | Refresh repositorie |
| zypper install vim | Install the package vim |
| zypper remove vim | Remove the package vim |
| Run command on $HOST as $USER (default command=shell) | ssh $USER@$HOST command |
| Run GUI command on $HOSTNAME as $USER | ssh -f -Y $USER@$HOSTNAME xeyes |
| Copy with permissions to $USER's home directory on $HOST | scp -p -r $USER@$HOST: file dir/ |
| Forward connections to $HOSTNAME:8080 out to $HOST:80 | ssh -g -L 8080:localhost:80 root@$HOST |
| Forward connections from $HOST:1434 in to imap:143 | ssh -R 1434:imap:143 root@$HOST |
| Download a set of files to the current directory | wget -r -nd -np -l1 -A '*.jpg' http://www.example.com/dir/ |
| Curl, use the -I flag to see the header and HTTP status code. | curl -I google.ca |
| Copy with permissions to $USER's home directory on $HOST | scp -p -r $USER@$HOST: file dir/ |
| Copy with permissions to $USER's home directory on $HOST | scp -p -r $USER@$HOST: file dir/ |
| Show status of ethernet interface eth0 | ethtool eth? |
| Manually set ethernet interface speed | ethtool --change eth0 autoneg off speed 100 duplex full |
| how to configure an IP address manually | ifconfig eth0 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255 |
| Get your IP address | ifconfig | grep "inet addr" | grep -v "127.0.0.1" | awk '{print $2;}' | awk -F':' '{print $2;}' |
| Get your public IP address | wget -qO- whatismyip.org |
| Ping all hosts at once from your /etc/hosts file | grep -v "#" /etc/hosts | awk '{print $1}' | while read host;do ping -c 1 $host;done; |
| Adding and Removing a Network in Linux | route add -net 10.125.0.0/18 gw 192.168.180.1 route del -net 10.125.0.0/18 gw 192.168.180.1 |
| Use traceroute to track the route a packet takes on the internet | traceroute FQDN or IPADDR |
| List active connections to/from system | netstat -tup |
| Show network route | netstat -nrv |
| Show how many active connections there are to apache (httpd runs on port 80) | netstat -an |grep :80 |wc -l |
| Show if ssh is active | netstat -ant |grep 22 |
| Lookup whois info for hostname or ip address | whois FDQN/IPADDRESS |
| Show network traffic except ssh | tcpdump not port 22 |
| HTTP trafic only | tcpdump -i eth0 -Xvvv port 80 |
| If you just want to capture FTP traffic with tcpdump | tcpdump -i eth0 -vvv port ftp |
| If you just want to capture FTP traffic to a file | tcpdump -i eth0 -vvv port ftp -w ftp.pcap |
| Scan computer with nmap | nmap 192.168.0.1 |
| Scan entire Network for Netbios / SMB with nmap | nmap -p 139 192.168.0.* |
| nmap, Intense Scan | nmap -T4 -A -v 192.168.0.1 |
| nmap, Quick Scan | nmap -T4 -F 192.168.0.1 |
| Scan for valid TCP connections | nmap -sT -T 5 -p 1-5000 192.168.0.1 |
| Output of nmap, greppable. | nmap -p 23 192.168.0.* -oG telnet.txt |
| Get the IP addresses | dig FQDN A +noall +answer |
| Get a list of all the mailservers | dig FQDN MX +noall +answer |
| Get a list of authoritative DNS servers | dig FQDN NS +noall +answer |
| Get a list of all the above | dig FQDN ANY +noall +answer |
| How to keep your computer from answering to ping! | echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all |
| Route packets on Linux! | echo 1 > /proc/sys/net/ipv4/ip_forward |
| List interfaces | ip link show |
| List address of interfaces | ip addr show |
| Add (or del) ip and mask (255.255.255.0) | ip addr add 192.168.0.1/24 brd + dev eth0 |
| ss - another utility to investigate sockets | ss -s |
| Using dstat for disk i/o, and network throughput | dstat -dnyc -N eth0 -C total -f 5 |
| Using the time plugin together with cpu, net, disk, system, load, proc and topcpu | dstat -tcndylp -M topcpu |
| Very long output, on dstat behaviour | dstat -taf --debug |
| Find cpu speed on the command line. | sysctl machdep.cpu.brand_string |
| As MacBook owner I have issues with heat, and one of the things I did was to disable "Spotlight" | sudo mdutil -a -i off ; to re-enable: sudo mdutil -a -i on |
| MacBook, heat issues! | smcfancontrol ; Fan Control |
| Applejack, troubleshooting assistant | AppleJack |
| A must for all Mac Users. | QuickSilver ; Blacktree |
| Clear you Mac's Cache! | dscacheutil -flushcache |
| Eject a Stubborn CD | disktool -e disk |
| Re-index Sportlight | sudo mdutil -E / (then do this) sudo mdutil -i on / |
| Add Spaces to Your Dock | defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}' |
| Disable the Dashboard | defaults write com.apple.dashboard mcx-disabled -boolean YES |
| To lower the heat in a mac laptop, disable spotlight on the unit. | sudo mdutil -i off /path-to-volume |
| FrontRow is missing from Lion, I do not know why Apple have chosen to remove it! | Here is how to get it back! FrontRow There is an issue with the new iTunes, but I mostly use it for movies! |
| OS X MacPorts; Please use sudo for all commands | |
| port selfupdate | Updates the tree |
| port installed | Shoes installed ported APPS |
| port -f uninstall installed | Un-installes Everything |
| defaults write com.apple.finder AppleShowAllFiles YES | Make all hidden files visible :-) Use at own discretion. |
| Command-Shift-3: | Take a screenshot of the screen, and save it as a file on the desktop |
| Command-Shift-4 | then select an area: Take a screenshot of an area and save it as a file on the desktop |
| Command-Control-Shift-3 | Take a screenshot of the screen, and save it to the clipboard |
| Command-Control-Shift-4 | then select an area: Take a screenshot of an area and save it to the clipboard, then past into doc |
| Management Console Shortcuts | Control Panel Shortcuts |
|
|
| When in a console window; Hit F7 for Command line history | Use F1 to past previous command on character a time ; F2 followed by a number ; F3 for previous command |
| Redhat | Debian | Backtrack | Suse |
| Tips 4 Linux | Tips - Computer | OSX Hints | SUSE Tips & Tricks |
| Microsoft | sysinternals | Windows Secrets | Windows Computer Tricks |
| Top 10 Virus sophos Now | Security, In the News | Top 10 Virus Symantec Now |
|---|
| Linux Security Issues | Ubuntu Security Issues |
|---|
| Microsoft Security Bullintin | Microsoft Security Advisory Now |
|---|