find / -name my filename with spaces.txt
=> find / -name "my filename with spaces.txt"
#
. A normal user prompt can be $
.
alias rm='rm -i -v' alias cp='cp -i -v' alias mv='mv -i -v' alias ..='cd ..' alias zznetstat='echo "Useful switches: -n (no dns), -p (process pid/name) or -c (continuous)";echo ;sudo netstat -a -A inet' alias zznetstat='echo "Useful switches: -n (no dns), -p (process pid/name) or -c (continuous)";echo ;sudo netstat -tanup' alias zz='/home/pi/streams' alias zzipt='echo;sudo iptables -nvL' alias zzhistsave='history -a' alias zzhistload='history -r'
$ find / -name FILENAME
$ find / -name FILENAME 2>/dev/null
(without error output)$ grep -rnw SEARCH_PATH -e "SEARCH_TEXT"
$ grep -Rnw SEARCH_PATH -e "SEARCH_TEXT" (seems -R better traverses directories)
$ grep --include=\*.{c,h} -rnw SEARCH_PATH -e "SEARCH_TEXT" (only search for .c and .h files)
$ grep --exclude=*.o -rnw SEARCH_PATH -e "SEARCH_TEXT" (exclude .o files)
$ grep --exclude-dir={dir1,dir2,*.dst} -rnw SEARCH_PATH -e "SEARCH_TEXT" (exclude some dirs)
$ cat file2 >> file1
# /etc/init.d/networking restart
# iptables-restore < your_rules_file
# iptables-save > /etc/iptables.myconf
# chmod +x /etc/network/if-pre-up.d/iptables
iptables
containing:#!/bin/sh /sbin/iptables-restore < /etc/iptables.myconf
# iptables-apply -t 60 your_rules_file
$ dpkg --get-selections
# apt-get autoremove
# apt-get clean
# apt-get check
cat /etc/localtime
[symlink] or cat track.mp3
), the console output gets garbled. You can still type and run commands, but some characters are not what they should be !echo
[CTRL]+V
[CTRL]+N
(there is a space after the echo).This is safer to use than echo-ing a binary file, as the binfile may not have the SI character (check the links if you wanna know what the [CTRL] codes mean).$ echo ^N
.roo├
. Type some words in a text editor (vi tmpfile
will be displayed as ┴i ├└p�i┌e
) and run some commands. ifconfig
if not sure (displayed as i�co┼�i±
).echo
[CTRL]+V
[CTRL]+O
, which renders $ ec░o ^O
.$ chmod +x FILENAME
).NC='\e[0m' # reset all attributes red='\e[31m' green='\e[32m' purple='\e[35m' cyan='\e[36m' yellow='\e[33m' orange='\e[38;5;202m' bold='\e[1m' underline='\e[4m' dim='\e[2m' blink='\e[5m' reverse='\e[7m' # invert bg and fg colors hidden='\e[8m' # for passwordsTo use them:
echo -e "Trees have ${green}green leaves"
=> Trees have green leaves
echo -e "Trees have ${green}green${NC} leaves"
=> Trees have green leaves
echo -e "Day ${reverse}Night${NC} Day"
=> Day Night Day
echo -e "Day \e[7mNight\e[0m \e[38;5;202mDay"
=> Day Night Day
echo -e "\e[32mOnline\e[0m it is"
=> Online it is
echo -e "\033[32mOnline\e[0m it is"
=> Online it is
: <<'some_string' This is an abuse of the null command ":" (colon) and the heredoc syntax Do not forget the quotes, it's to make sure no expansion of this text is taking place some_string
u
/ CTRL+r
Display line numbers: :set number
. Remove: :set nonumber
:set cursorline
:set hlsearch
. Remove until next search: :nohlsearch
or simply :noh
. Remove: :set nohlsearch
:w
:q
:wq
:q!
i
dd
dxd
or xdd
yy
p
ddp
dd (or dxd)
to cut, then p
to paste.gU
then left or right arrow (left for previous letter, right for current)gu
+ arroww
, so: gUw or guw
. Note that it will only apply FROM the position IN the word where the cursor is.END
, like gu<END>
or gU<END>
. Same note as above.gUU
/gUu
or VU / Vu
gUiw
or guiw
/text_to_search
. It's a regular expression. Press n
for the next item found. To highlight searched text, see above.:g/text_to_search
(displaying line numbers is helpful, see above).:g!
or v
(g!/text_to_search
v/text_to_search
).:g/text_to_search/d
.:g/^\s*$/d
# Enable mouse scrolling and scroll bar history scrolling
termcapinfo xterm* ti@:te@
screen -ls
screen -d -R $SCREEN_NAME_OR_ID
screen -t $SCREEN_NAME $COMMAND
<-- TO CHECKCTRL+A
CTRL+a
then Escape
. Now the nav keys can be used to navigate through the output. Press Enter
twice to get back to write mode.CTRL+a
then d
(like detach).CTRL+D
copy /b partfile.* bigfile.ext
copy /b partfile.1+...+partfile.n bigfile.ext
copy /b log* all_logs.txt
copy /b *.bat big_script.bat
copy /b file1+log+name2 bigfile.ext