nyan~

Engineering Rocks!

Ubuntu Tips

bash

Run bash terminal as a login shell

~/.profile
1
2
3
4
5
6
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

vim

vim cheatsheet

1
2
3
4
5
6
7
.               # Position of the last change
' or `          # Position before last jump
`. or '.        # Go back to last edit top
:               # command mode
:set paste      # auto indent for code paste
:set number     # display line number
:1,$s/<target string>/<replace string>/ # replace strings

cscope

1
2
3
cscope -bkR     # create tags
ctrl-]          # go to symbol
ctrl-t          # return to last tag stack

tmux

1
2
3
4
5
6
7
tmux ls                             # list tmux sessions
tmux new session -s [session name]  # create new session
tmux attach -t [session name]       # attach session
ctrl-b + c                          # create new window
ctrl-b + ,                          # rename window
ctrl-b + w                          # switch windows
ctrl-b + s                          # switch sessions

shellscript

declare integer
1
2
3
declare -i y=10
declare -i z=0
z=$(( x + y ))
while loop
1
2
3
4
5
6
loop=0
while true;
do
loop=$(($loop+1))
echo $loop
done
rename folder
1
2
3
4
5
for NAME in `ls`;
do
    NEWNAME=`echo $NAME | tr -d 'bug'`;
    mv $NAME $NEWNAME;
done

remote desktop

  • Access Windows OS Desktop
1
rdesktop -u "[domain name]\[account]" -g 1920x1080 -D [ip address]
  • Access Ubuntu Shared Folders

Check link

mount

  • Samba
1
2
3
sudo apt-get install cifs-utils
sudo mkdir /media/test/
sudo mount.cifs //[path to share folder] /media/test/ -o username=[account],password="[password]"
  • ISO Image
1
2
sudo mkdir /media/iso/
sudo mount [file].iso /media/iso/ -t iso9660 -o loop

Useful utility

  • man: on-line reference manuals interface
1
$man -f <utility|function>
  • axel: A light download accelerator for Linux
1
$axel -n <number of connections> <link to file>
  • gqview: read raw file

  • ffmpeg: strip video from file

1
$ffmpeg -i sling60.ts -an -vcodec copy avc.ts
  • date
1
$date +%G%m%d-%H%M%S
  • tcpdump
1
$tcpdump -i any -s 2048 -tt -n -vvv -xX -w <log.txt>