Cheat Sheet :: Linux Shell Tricks
To find the corresponding hex code
| |
How to redirect standard error in bash
| Command | Description/Purpose |
|---|---|
| command 2>filename | Redirect stderr to filename |
| command >output 2>filename | Redirect stderr to file named filename and stdout to file named output |
| command &> filename | Redirect stderr and stdout to filename |
| command 2>&- | Just suppress error messages. No file created. No error message displayed on screen |
| command 2>/dev/null | Just suppress error messages. |
| command 2>&1 | Redirect error messages to standard output. Useful in shell script when you need to forcefully display error messages on screen |
Removing blank spaces and special chars
Note that we cannot just type the accent ^, instead we must use CTRL+V and then type CTRL+M.
Using Vim Editor
If you want to remove blank lines (using vi):
:g/^$/dFor commented lines (using vi):
:g/^#/dFor lines where windows editor put ^M and you want to remove (using vi).
:%s/^V^M//gThe final command will look like this:
:%s/^M//g
Using sed
| |
Using Dos2Unix
| |
Using tr
To delete a CRLF:
| |
Using egrep
| |
Using grep
| |
Interactive shell
Using rlwrap
| |
Using python
- Once you have a shell on the victim:
| |
Or
| |
- Press CTRL+Z
- On attacker’s machine:
| |
- Now press
fgto get the shell back
Backup of files permissions
- To create the permission file
| |
- To restore the permissions from file
| |
Smart management of soft links with stow
- Installation
| |
- Managing soft links
| |
| |
| |
| |
| |