Skip to content

Instantly share code, notes, and snippets.

@yangg
Created July 3, 2011 13:41
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save yangg/1062232 to your computer and use it in GitHub Desktop.
Shell scripts(Ubuntu)
Mint
# screenlets
# Show bandwidth use oneliner
while true; do cat /proc/net/dev; sleep 1; done | awk -v dc="date \"+%T\"" '/eth0/{i = $2 - oi; o = $10 - oo; oi = $2; oo = $10; dc|getline d; close(dc); if (a++) printf "%s %8.2f KiB/s in %8.2f KiB/s out\n", d, i/1024, o/1024}'
# limit the cpu usage of a process
sudo cpulimit -p pid -l 50
# ubuntu root
sudo passwd root
sudo passwd -l root
sudo -i
update-alternatives --config x-www-browser
update-alternatives --get-selections | grep x-www-browser | sed -e 's/x-www-browser\s*auto\s*//'
browser=`update-alternatives --get-selections | grep x-www-browser | sed -e 's/x-www-browser\s*auto\s*//'`; $browser /usr/share/w3m/w3mhelp.html > /dev/null
apt-cache search package 搜索包
apt-cache show package 获取包的相关信息,如说明、大小、版本等
sudo apt-get install package 安装包
sudo apt-get install package - - reinstall 重新安装包
sudo apt-get -f install 修复安装"-f = --fix-missing"
sudo apt-get remove package 删除包
sudo apt-get remove package - - purge 删除包,包括删除配置文件等
sudo apt-get update 更新源
sudo apt-get upgrade 更新已安装的包
sudo apt-get dist-upgrade 升级系统
sudo apt-get build-dep package 安装相关的编译环境
apt-get source package 下载该包的源代码
sudo apt-get clean && sudo apt-get autoclean 清理无用的包
sudo apt-get check 检查是否有损坏的依赖
diff .bashrc .bashrc1 > .etc/.bashrc.patch
cat .bashrc.patch | patch .bashrc
patch -N .bashrc .etc/.bashrc.patch
# Re-start System without Rebooting
Ctrl + Alt + Backspace
Alt + PrintScreen + K
useradd / userdel
# Linux 用命令行查看硬件信息@evernote
cat /proc/cpuinfo
cat /proc/meminfo
rpm -Uvh pkg.rpm
/etc/environment
/etc/hosts
/etc/passwd
# List your MACs address
cat /sys/class/net/eth0/address
F3
mkdir -p aa/bb/cc && cd $_
cd !$
# Esc + . 可以切换之前命令的参数
# !! repeat the previous command
# !$ repeat the last argument of the previous command
# http://ss64.com/bash/history.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment