A collection of useful linux commands and other stuff.
OS X: brew install ngrep
ngrep -d en1 -q -W byline "GET"
Exclude matching string using grep. Use v
argument with grep.
tail -f access.log | grep -v 'HEAD'
This will exclude all the HEAD requests from access.log
file.
pgrep celery
~/.ssh/config
- Create this file if doesn't exist.
Add the following contents
Host dev-machine
HostName dev.example.com
Port 22
User apps
You can invoke ssh as ssh dev-machine
pgrep flower | xargs kill
flower -A blog &
&
sends the job to background.
You can check the background jobs using jobs
The fuser command is a very smart unix utility used to find which process is using a file, a directory or a socket. It also gives information about the user owning the process and the type of access. The fuser tool displays the process id(PID) of every process using the specified files or file systems.
fuser -n tcp 80
Lists all the processes that are using port 80.
List the pids of the process listening on port 3000.
lsof -i tcp:3000
To only display the pid's use the terse option.
lsof -t -i tcp:3000
Also another usage
lsof -i :3000
strace It intercepts and records the system calls which are called by a process and the signals which are received by a process. The name of each system call, its arguments and its return value are printed on standard error or to the file specified with the -o option.
strace -p 1234
strace -e open bash
ls /proc/30880/fd
where 30880 is the PID.
> tty
/dev/pts/0
Switch to another console.
echo "Hello World !" > /dev/pts/0
The text "Hello World !" would be printed in the first terminal.
Press Enter
~
.
diff -ru dir1/ dir2
For just the files that have changes
diff -rqu dir1/ dir2
mkfifo my_pipe
This is similar to shell pipe |
but uses a file instead.
xargs --null --max-args=1 < /proc/self/environ
The tty command returns the filename of the terminal connected to standard input
tty
echo $$
cd -
usermod -s /bin/bash <username>
chsh -s /bin/bash
sudo du -hs *
sudo du -h .
diskutil info / | grep "Block Size"
stat -f %k .
cat /etc/issue
Input/Output stats
The following will clear where bash thinks fab is located:
hash -d fab
This command updates the shell's hash of locations of commands