Jeg har i det siste skrevet inn nyttige kommandoer jeg bruker ofte i en notatfil på linux-maskinen min.
Jeg tenkte flere kanskje kan ha nytte av dette, så da spør jeg her,
hvilke linux kommandoer/verktøy (i terminalen) er det du bruker mest? Er det noe nyttig jeg ikke har nevnt i filen? :-)
Kommer til å oppdatere filen ettersom folk kommer med forslag.
https://gist.github.com/01d8fb3d3a9b4b146bf1
Jeg tenkte flere kanskje kan ha nytte av dette, så da spør jeg her,
hvilke linux kommandoer/verktøy (i terminalen) er det du bruker mest? Er det noe nyttig jeg ikke har nevnt i filen? :-)
Kode
# Tips & useful commands watch -n 1 -d <command> # run a command periodically and show the output, -n specifies interval, -d highlights changes. ctrl-x e # Invoke a editor to write a tricky long command. reset # Fixed a broken terminal. ssh-copy-id user@host # Copy SSH public keys to host to enable password-less SSH logins. sudo <command> # DANGEROUS Run a command as root, requires you to be in /etc/sudoers or a group that is, DANGEROUS. sudo !! # DANGEROUS. Run the last command as root. DANGEROUS column -t # Pipe any command to column -t to get a nice aligned output. apropos <word> # Search man pages. lsof -p <PID> # See what files a process has open. ps auxww -H # See all processes, with params + hierarchy. pgrep -fl node # See all node-related PIDs and processes. cd - # Change to last working dir strace -f -p <PID> # See what a process is doing (system calls), -f traces child processes (results of fork()), -p specify pid. tail -f file.log | grep 10.0.0.1 # Monitor a log file (or any file) for a string. !!:gs/foo/bar # Run previous command, replacing foo with bar everytime foo occurs. ctrl+u [...] ctrl+y # type partial command, kill this command, check something you forgot, yank the command, resume typing. # Example : # vim /etc/fstab # Woops, forgot sudo! # <ctrl+u> sudo <ctrl+y> # sudo vim /etc/fstab ps aux | sort -nk +4 | tail # Display the top 10 running processes, sorted by memory usage. ping -i 60 -a <ip> # Sound an audible bell alarm when a host comes online, useful for when you are waiting for something to reboot. -i is interval, -a is audible bell. history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head # Get the 10 most uses commands from your history. # Tools htop # Instead of top, htop is a process manager/monitor. ranger # File manager, vim-style. # Disk iostat -xnk 5 # Check read/writes per disk -x is extended statistics, -n shows NFS header row, -k displays statistics in kilobytes per second instead of blocks. Use -m for megabytes per second, 5 is the interval (must be installed, in apt package sysstat) df -h # Display an overview of all disks du -hs # Display disk usage of this directory and all sub-directories. find . -size +100M # Find all files in current directory over 100M. # Memory free -m # Show free memory, -m displays in megabytes. Learn how to read memory at: http://www.linuxatemyram.com/ cat /proc/meminfo # See information about memory # Network ssh -N -L2001:localhost:80 somehost # Start a tunnel from somehosts port 80 to localhost 2001. (You can go to http://localhost:2001 to hit somehost:80) python -m SimpleHTTPServer 8080 # Serves the local directory from 8080. lsof -i # Monitors network connections in real time. nethogs # Shows the bandwidth usage per process. (must be installed) netstat -tnlp # List all listening ports with PID of process. mtr google.com # mtr is better than traceroute and ping combined. lsof -nPi tcp # See all TCP sockets in use, -n disables hostname lookup (makes lsof faster), -P disables port name lookup, -i is used for matching addresses/protcols, like tcp. curl -LI http://google.com # -I display HTTP headers, -L follow redirects. iftop # Show traffic by port, install required, uses pcap. # Performance vmstat 1 # See state of your system, are we swapping? 1 is interval to call. time <command> # See how long a command takes to execute. # Vim commands :w !sudo tee % # Save a file you edited in vim without the needed permissions.
https://gist.github.com/01d8fb3d3a9b4b146bf1
Sist endret av flexd; 12. januar 2013 kl. 12:50.