Tips, Tricks, and Info!
Lennart Andersen Manjaro Bash Networking OSX MySql Links Linux News 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

#Manjaro   Top
yaourt -Suy Refresh repositories
yaourt -S vim vim-runtime Install the package vim
yaourt -R vim Remove the package vim
#Bash   Top
  • Ctrl-a - Move to the start of the line.
  • Ctrl-e - Move to the end of the line.
  • Ctrl-b - Move back one character.
  • Alt-b - Move back one word.
  • Ctrl-f - Move forward one character.
  • Alt-f - Move forward one word.
  • Alt-] x - Where x is any character, moves the cursor forward to the next occurrence of x.
  • Alt-Ctrl-] x - Where x is any character, moves the cursor backwards to the previous occurrence of x.
  • Ctrl-u - Delete from the cursor to the beginning of the line.
  • Ctrl-k - Delete from the cursor to the end of the line.
  • Ctrl-w - Delete from the cursor to the start of the word.
  • Esc-Del - Delete previous word (may not work, instead try Esc followed by Backspace)
  • Ctrl-y - Pastes text from the clipboard.
  • Ctrl-l - Clear the screen leaving the current line at the top of the screen.
  • Alt-r - Undo all changes to the line.
My favourite common alias links
  • alias ll='ls -l'
  • alias la='ls -A'
  • alias l='ls -lA'
  • alias mutt="mutt -y"
  • alias gf="find . -type f -print0 | xargs -0 -e grep -n -e"
  • alias gf-color="find . -type f -print0 | xargs -0 grep -i -n -I --max-count=50 --color=always"
  • alias xtop="xterm -e top"
  • alias clr='clear;echo "Currently logged in on$(tty), as $(whoami) in directory $(pwd)."'
  • alias tgz='tar -cvvzf'
  • alias tbz2='tar -cvvjf'
  • alias utgz='tar -xvvzf'
  • alias utbz2='tar -xvvjf'
  • alias mktar='tar -cvvf'
  • alias untar='tar -xvvf'
  • alias nano='nano -w'
  • alias df='df -h'
  • alias vi="vim"
  • alias server_name="ssh -l user ipaddress"
  • alias findbigfiles="find . -type f -exce ls -s {} \; | sort -n -r | head -5"
  • alias psf="ps -e f"
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
  • perl -i -pe 's/windows/linux/;' test*
  • find . -name '*.txt' -print | xargs perl -pi -e's/Windows/Linux/ig' *.txt
  • find -type f -name '*.txt' -print0 | xargs --null perl -pi -e 's/Windows/Linux/'
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
#Networking   Top
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'
Curl, use the -I flag to see the header and HTTP status code. curl -I
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 netmask broadcast
Get your IP address ifconfig | grep "inet addr" | grep -v "" | awk '{print $2;}' | awk -F':' '{print $2;}'
Get your public IP address wget -qO-
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 gw
route del -net gw
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
Scan entire Network for Netbios / SMB with nmap nmap -p 139 192.168.0.*
nmap, Intense Scan nmap -T4 -A -v
nmap, Quick Scan nmap -T4 -F
Scan for valid TCP connections nmap -sT -T 5 -p 1-5000
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 ( ip addr add 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
#OSX   Top
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 persistent-apps -array-add '{"tile-type"="spacer-tile";}'
Disable the Dashboard defaults write 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 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
#MySql   Top
Login to MySql from command line mysql -u user -p password
Create database create database dbname;
Give user privileges grant all privileges on dbname.* to user@localhost; then, flush privileges;
Allow the user "user" to connect to the server from localhost using the password "123456" grant usage on *.* to user@localhost identified by '123456'; then, flush privileges;
#Links   Top
Kali Linux Distro Manjaro Arch Linux Debian
Arch Linux Wiki Tips - Computer OSX Hints Dotfiles
MySql 50 Most Frequently Used cmds Linux/Unix
#Linux-News   Top
Linux Security Issues Ubuntu Security Issues Linux Today
Geek Stuff Command line fu Linux dot com
#Virus-Security-Info   Top
Top 10 Virus sophos Now Security, In the News Top 10 Virus Symantec Now

Lennart Kim Andersen