linux
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
linux [2021/01/22 20:03] – roger | linux [2024/11/17 12:59] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
Useful Linux commands, with no particular order | Useful Linux commands, with no particular order | ||
- | ==== Check which program is using a particular port ==== | + | ===== Check which program is using a particular port ===== |
| | ||
<code bash> | <code bash> | ||
- | ==== Kill a particular PID ==== | + | ===== Kill a particular PID ===== |
<code bash> | <code bash> | ||
- | ==== Check the current folder size ==== | + | ===== Check the current folder size ===== |
<code bash>du -hs .</ | <code bash>du -hs .</ | ||
- | ==== Show filesystem information ==== | + | ===== Show filesystem information |
<code bash>df -h</ | <code bash>df -h</ | ||
- | ==== SSH ==== | + | ===== SSH ===== |
More info: https:// | More info: https:// | ||
- | === Copying local keys to a remote server === | + | ==== Copying local keys to a remote server |
<code bash> | <code bash> | ||
- | === Create a remote tunnel into localhost === | + | ==== Create a remote tunnel into localhost |
<code bash>ssh -L local-port: | <code bash>ssh -L local-port: | ||
Line 32: | Line 32: | ||
Note: '' | Note: '' | ||
- | + | ==== Forward a local port to a remote host (like ngrok) | |
- | === Forward a local port to a remote host (like ngrok) === | + | |
<code bash>ssh -N -T -R local-port: | <code bash>ssh -N -T -R local-port: | ||
Line 41: | Line 40: | ||
* -R Specifies that connections to the given TCP port or Unix socket on the remote (server) host are to be forwarded to the local side. | * -R Specifies that connections to the given TCP port or Unix socket on the remote (server) host are to be forwarded to the local side. | ||
- | === SCP === | + | ==== SCP ==== |
<code bash>scp -r / | <code bash>scp -r / | ||
- | ==== tar & untar ==== | + | ===== tar & untar ===== |
- | === tar === | + | ==== tar ==== |
<code bash>tar -czvf file.tar.gz file/ | <code bash>tar -czvf file.tar.gz file/ | ||
Line 56: | Line 55: | ||
* -f filename | * -f filename | ||
- | === untar === | + | ==== untar ==== |
<code bash>tar -xvf file.tar.gz</ | <code bash>tar -xvf file.tar.gz</ | ||
Line 64: | Line 63: | ||
* -f filename | * -f filename | ||
- | ==== gpg encrypt/ | + | ===== gpg encrypt/ |
- | === Encrypt === | + | ==== Encrypt |
<code bash>gpg -c --cipher-algo AES256 file/ | <code bash>gpg -c --cipher-algo AES256 file/ | ||
Line 72: | Line 71: | ||
You will be asked to enter a password | You will be asked to enter a password | ||
- | === Decrypt === | + | ==== Decrypt |
<code bash>gpg file/ | <code bash>gpg file/ | ||
You will be asked to enter a password | You will be asked to enter a password | ||
+ | |||
+ | ===== Download an entire website using wget ===== | ||
+ | |||
+ | More: https:// | ||
+ | |||
+ | <code bash> | ||
+ | wget \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ===== Create a X.509 sha256 self signed certificate ===== | ||
+ | |||
+ | <code bash> | ||
+ | openssl req \ | ||
+ | -x509 \ | ||
+ | -newkey rsa:4096 \ | ||
+ | -sha256 \ | ||
+ | -keyout mykeyname.key \ | ||
+ | -out mycertname.pem \ | ||
+ | -days 365 | ||
+ | -nodes # only if you need no password | ||
+ | </ | ||
+ | |||
+ | ===== Find ===== | ||
+ | |||
+ | ==== Find a specific file in the specified folder ==== | ||
+ | |||
+ | You can use: | ||
+ | |||
+ | <code bash> | ||
+ | find mypath -type f -name " | ||
+ | </ | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | ===== xargs ===== | ||
+ | |||
+ | '' | ||
+ | |||
+ | <code bash> | ||
+ | find . -type f -name \" | ||
+ | </ | ||
+ | |||
+ | What's happening? | ||
+ | |||
+ | * First, we are performing a [[linux# | ||
+ | <code bash> | ||
+ | ./ | ||
+ | ./ | ||
+ | </ | ||
+ | * Then, we pipe the output of the find command to '' | ||
+ | * '' | ||
+ | |||
+ | |||
+ | This command in particular is very usefull to check if all the JSON files in a repository are well formated in a CI/CD step. | ||
+ | |||
+ | ===== ncdu ===== | ||
+ | |||
+ | Ncdu is a disk usage analyzer with an ncurses interface. It is designed to find space hogs on a remote server where you don’t have an entire graphical setup available, but it is a useful tool even on regular desktop systems. Ncdu aims to be fast, simple and easy to use, and should be able to run in any minimal POSIX-like environment with ncurses installed. | ||
+ | |||
+ | Usage: | ||
+ | |||
+ | <code bash> | ||
+ | ncdu -x / | ||
+ | </ | ||
+ | |||
+ | Where ''/'' | ||
+ | |||
+ | ===== awk ===== | ||
+ | |||
+ | ==== Print the first column of a string ==== | ||
+ | |||
+ | <code bash> | ||
+ | echo "This is a string" | ||
+ | # Output: " | ||
+ | </ | ||
+ | |||
+ | ==== Print a full string in lowercase or uppercase ==== | ||
+ | |||
+ | <code bash> | ||
+ | echo "This Is A CaPiTaLiZeD String" | ||
+ | # Output: "this is a capitalized string" | ||
+ | |||
+ | echo "This Is A CaPiTaLiZeD String" | ||
+ | # Output: "THIS IS A CAPITALIZED STRING" | ||
+ | </ |
linux.1611345835.txt.gz · Last modified: 2024/11/17 12:59 (external edit)