- If vim paste is messed up, then do
:set paste
Get the output of grep --color=auto -ril "keyword" .
and sort it according to modify date.
find . -type f -exec grep -q keyword {} \; -printf '%T@/%p\0' | sort -zn | while IFS=/ read -rd '' tsamp file; do printf 'timestamp: %s, file: %s\n' "$tsamp" "$file"; done
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt
- As seen here - https://help.ubuntu.com/community/LiveCDCustomization#Assembling_the_file_system
man tmux | grep -B1 -E '\(alias:' | grep -vE '^-' | tr '()' ' ' | perl -pe 's/\s*\z/ / unless /alias:/' | awk '{printf "%s %s\n", $1, $NF}' | column -t | sort
- See all tmux commands and aliases.
command | while IFS= read -r line; do printf '[%s] %s\n' "$(date '+%Y-%m-%d %H:%M:%S')" "$line"; done
Attention: Sometimes however, you have to redirect stderr into it (using something like command 2>&1 | timeloop ...
) - (Source)
- read determines if a user can view the directory's contents, i.e. do
ls
in it. - write determines if a user can create new files or delete file in the directory. (Note that this essentially means that a user with write access to a directory can delete files in the directory even if he/she doesn't have write permissions for the file! So be careful with this.)
- execute determines if the user can
cd
into the directory.
ls -d .[^.]*
diff <(ls /tmp/folder1) <(ls /tmp/folder2) # diff output of 2 commands
diff -r /tmp/folder1 /tmp/folder2 # diff 2 dirs
alias apaste='curl -F '\''paste=<-'\'' http://apaste.info/store'
echo just testing! | nc termbin.com 9999
- Needs nc to be present on the system.
mount -o loop disk.iso /mnt/disk
- Source
badblocks -nsv -p2 -o ./badblocksresult.txt /dev/sdX
Badblocks is not perfect though. - (archive)
watch -n 1 killall -USR1 dd
grep -i 'w1.*w2\|w2.*w1' <filename>
git fetch && git status | grep behind
- Source
.tmux.conf
even when prefix key doesn't worktmux source-file ~/.tmux.conf
- Add a UTF8 character to tmux window indicator
tmux setw -g window-status-format "#(perl -C -E'\$_=shift, say chr( \$_ ? 0x245f + \$_ : 0x24ea)' #I) :#W"
- tmux 2.0 vs. 2.1
python -m SimpleHTTPServer <port>
If port is unspecified, 8000 is default.
curl --head example.com | awk 'NR==1{ print $2 }'
wget --spider URL
curl --head URL
curl wttr.in/amsterdam
curl wttr.in ### Automatically determines location based on IP address
sudo nmap -sP "192.168.1.*"
- Works only if ICMP packets are allowed.
tar -cvWf archive_name.tar dir_name
tar -xvf archive_name.tar
If you don't want to memorize all of that stuff, there's also dtrx (Do The Right Extract).
gpg -ac archive_name.tar
gpg -d archive_name.tar.asc > archive_name.tar
rsync -avPHSxh
rsync -avPHSxh -e 'ssh -p 2222 -i .ssh/privkey' user@remote:/full/path /local/path/
The -p
argument is if you're on a custom port, which you should be on.
Also, watch out for rsync over FUSE.
ssh-keygen -t rsa -b 4096 -a 100 -f ~/.ssh/name_of_key -C <optional_comment>
- partially modified from Stribika's Secure Secure Shell article
ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub
- Source
This might be best illustrated with an example. Let's say that find turns up these files:
file1
file2
file3
Using -exec
with a semicolon (find . -exec ls '{}' \;
), will execute
ls file1
ls file2
ls file3
But if you use a plus sign instead (find . -exec ls '{}' \+
), all filenames will be passed as arguments to a single command:
ls file1 file2 file3
find path -type f -exec sed -i 's/string1/string2/' {} \;
find . -iname "*searchterm*" ! -path "./excluded_dir/*" ! -path "./excluded_part_of_dirname*"
find . -iname "*searchterm*" ! -iname "*.html" ! -iname "*.js"
rpm -q --changelog glibc | head
sudo yum history packages-info "*" | less
- On most yum versions:
yum list installed | grep @repo
- On more recent yum versions:
yumdb search from_repo repoid
- Explanation
sudo yum -v clean all
Case: sudo: add-apt-repository: command not found
Solution: sudo apt-get install software-properties-common
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | less