I've added this cheatsheet function to my .bashrc which I also find useful:
function cheat { curl "https://cheat.sh/$1" }
For example compare
man rsync
with
cheat rsync
Be careful about running any command you find on the internet though. A lot of people like to troll and tell you to run sudo rm -rf /
which deletes every file from your system.
Sudo is “super user do” basically the equivalent of run as administrator in windows, it runs whatever comes after it with root level permission. rm is “remove” and can remove files like so “rm /path/to/file” The -rf after rm is a flag (dashes are flags used to specify certain functionalities in commands, different for each command), the r is “recursive” which means it will delete all files and folders it finds from your path, and f is “force” to tell rm to disregard errors and just delete. The / is the root directory, basically equivalent to C: on windows.
https://cheat.sh is really good for quickly finding out usages of some commands. You can also most of the time use “man <insert command here>” (stands for manual) and you’ll get an overview of the command in question and it’s flags.
You can search through the man pages with /
.
They're also available offline, they don't require switching to a different application, and they are more accurate (you won't get the manual for a version of the program that you don't have installed).
I love https://cheat.sh/ though. Especially when I need to do something simple with a command I don't use often.
You need a degree in virginity to understand man pages apparently, so I added this to my bashrc:
wtfis() { curl "https://cheat.sh/$1"}
then you can do wtfis ls and see the most used commands in a perfectly readable format
It took me less than a minute to get it without getting worried about the Node. Use sudo get install tldr
Or maybe you can use this if you don't like Node: curl https://cheat.sh/tar
Just make sure you have curl!
It looks like https://cheat.sh/ is sniffing User-Agent to serve HTML to "normal" browsers and serve plain-ish text with embedded escape characters to console-based clients.
If you want to write out the HTML you can spoof a desktop browser:
iwr https://cheat.sh/c/:learn -Headers @{'User-Agent;='Mozilla/5.0'} -OutFile ./cheatsh.c
If you want plain text you can append ?T
to the URI:
iwr https://cheat.sh/c/:learn?T -OutFile ./cheatsh.c
If you just want to see the syntax-highlighted response in your terminal, you can use Invoke-RestMethod instead of Invoke-WebRequest:
irm cht.sh/c/:learn
So your ducky needs to be prepared for windows (curl is wayyy different on windows, so you'll have to check that out) and then all other computers use the same curl, so you could curl cheat.sh for example. That would let you download the output from https://cheat.sh, a website full of tutorials to be viewed from command line.
Let's say you have a website that hosts a .txt file containing a whole bunch of python code (it doesn't matter that it's a .txt) you would run curl https://yourwebsite.com/notes.txt > hacks.py
. This let's you do tons of stuff! Your txt could have huge packages needed to perform other hacks, or your website could be used to receive data, in which case your ducky would need to be programmed to POST curl to your website.
One cool command line tool to use is https://cheat.sh
There is command line tool installation guide at https://github.com/chubin/cheat.sh
Or you can just use ex.
curl cheat.sh/tar
I added this to my ubuntu config, nyt changed cht.sh to cheat for easier use from command line (auto completion works better with that)
These two might be what you're after?
>Even better if there is like a snippet file I can maintain with placeholders for common items I use.
People tend to build those into aliases or functions and put them in their dotfiles.
Yes! The ArckWiki is a major resource for myself, and should be for anyone serious about learning technologies in Linux.
By the way, You've just taught me something. Never heard of Cheat.sh before today. Installing later. Does it help one learn about command usage, or simple provide quick answers to common problems?
Don't forget all of the great search and help commands
help [command]
[command] --help
apropos
find
which
whereis
It's OK to rely on notes. Over time the things you do regularly will be committed to memory and the rest will be in your notes. We ALL have notes. Some good helpers:
apropos <key word>
help <builtin shell command
tar --<tab>
shows possible options.Create a VM or buy a Raspberry Pi, come up with a project like installing a Nextcloud server, install it via cli, administer it via cli. If you have an Android phone, download Termux and learn how to SSH into it. In addition to man pages for learning syntax, I like to use cheat.sh (a website) to get command examples. For instance to learn about the rsync command, go to cheat.sh/rsync. You can even do it from the command line with curl cheat.sh/rsync
In your terminal, type.
curl
<code>cheat.sh</code>Then follow what you see.
Or if you are looking for commands and their usage, run the following.
compgen -c
Then man <command>
or info <command>
for the specific ones that look interesting to you.
check out <code>thefuck</code> in the community repo.
❯ cat .zsh.d/aliases.zsh alias ll='ls -lah --group-directories-first' alias ..='cd ..' alias venv="python -m venv .venv --prompt $(basename $(pwd))" alias systimers="systemctl list-units --type=timer" alias sysservices="systemctl list-units --type=service" alias sysstart="sudo systemctl start" alias sysstop="sudo systemctl stop" alias sysrestart="sudo systemctl restart" alias sysstatus="sudo systemctl status" alias sysenable="sudo systemctl enable" alias ping='ping -c 4' alias uuid='sudo blkid -s UUID -o value'
function mkcd () { mkdir -p $1 && cd $1 }
function wiki() { search_term=$(echo $@ | sed 's/ /+/g') lynx https://wiki.archlinux.org/index.php\?search\=${search_term} }
function wtfis() { curl "https://cheat.sh/$1" }
Hey, a website that might help you is cheat.sh (or cht.sh), they host a bunch of cheatsheets, with syntax highlighting (colors), the main advantage being that it's available from the command prompt (but the browser also works if you prefer).
To get help for a specific tool or command, you have to access cheat.sh/yourtool, for nmap, that would be cheat.sh/nmap.
As I said, you can access it from the terminal, by using curl: curl -q cheat.sh/nmap
(here, -q means quiet, it hides curl's download stats)
Quality of life Aliases:
`alias ls="ls -A --color"` #some people add l too
`alias grep="grep --color"`
Try `zsh` instead of `bash` (just for the autocomplete and the esthetics).
Learn how regular expressions works. Everything in Linux is a text file. The better your ability to manipulate test the most efficient you are.
​
`tldr` - simplified and community man pages, you can also try `curl cheat.sh/command`
`glance` - task manager in steroids
`locate` - uses a database to find files super fast
`time` - you can see how long it takes for an command to run
`netstat` or `ss` - to check your ports
`cut` - easy and fast way to cut text from output
`curl` - great tool to transfer data from urls
`watch` - you can force a command to write the screen in specific intervals
`fail2ban` - create jails
`iptables` - create firewall rules
Since nobody has mentioned it, cheat.sh can access tldr's pages.
Aaaaand you can just use curl together with that:
$ curl cheat.sh/pacman
Hell, you can make a small shell function for it and plop it in your rc file for your shell:
tldr() {
curl cheat.sh/$1
}
And with some fallbacks:
tldr() {
[ "$1" != "" ] && {
curl cheat.sh/$1
}
}
Instead of installing tldr
in short this makes your workflow more portable and require less external tools...
I am looking for the database of this project. Is there anyone who knows a fast way of obtaining code entry (.i.e like this)? I need to show multiple of these in a single page, like a search engine.
Add a function to .bash_aliases
or .bashrc
to make it a bit quicker to type.
I call mine cs for cheat*s*heet. For example: cs btrfs
function cs() { curl -m 7 "https://cheat.sh/$1"; }
There is newer attempts on help users to provide good examples, like https://tldr.sh/ and cheat.sh. The manual pages are often more comprehensive . But sometimes you just need a few examples.
I like to add color to the man pages and also use the "programname --help" flags.
use the / to search and "q" key to quit man pages.
> EDIT: I don't understand downvotes. I just described what the situation is, and tried to be quite constructive and describe where the problem is. These are the reasons why I believe people don't use manpages much.
Downvotes are probably because people disagree with you. For instance:
> I've been thinking a lot how Man pages are nearly useless nowadays
You may find them useless, but myself (and obviously a lot more people) find them very useful.
> dreamed about a project of "new man pages" that would produce manuals that would give you fast and straightforward examples of typical usage
This does exist in many different forms, e.g. https://cheat.sh.
> instead of listing all the cumbersome and rarely used flags in alphabetical order (like many man pages do).
Which is sort of the point: man pages should be the full reference of a CLI tool, including the various (both cumbersome and rarely used) flags.
Sorry about that. I am so used to having less
on all of my computers. I love being able to scroll and search on the results.
You could probably just throw away the try/catch and/or even output directly to the console.
I found out about Cheat.sh a few months ago. If you are on bash there is a premade script, but Powershell didn't have one so I made this short work around. It is extremely convenient to search for tips from a terminal.
I found links in your comment that were not hyperlinked:
I did the honors for you.
^delete ^| ^information ^| ^<3
For all the commands you do know: Everytime you encounter a problem you don't know how to solve, there's probably some program made to solve it, use google extensively.
For commands I do know but forgot how to use correctly there's cheat.sh. It shows the most used commands with examples.
Add this to your rc file to use it e.g. like cheat tar
in your terminal
function cheat() { IFS='-'; curl https://cheat.sh/$*; }
I asked a similar question here.
Added a function to my .bash_aliases like so:
# Ask Cheat.sh website for CLI examples, like: cs lsof function cs() { curl -m 7 "https://cheat.sh/$1"; }
The output suggests that you probably have a space somewhere and you end up running:
$ curl cheat.sh/ tar.
By the way:
man lolcat
EXAMPLES
Typical combinations of lolcat include other programs that generate text: Large colorful words can be written like this:
echo "KTHXBAI" | toilet | lolcat
Cows are popular, come in all colors, and tell random epigrams:
fortune | cowsay | lolcat -a
Return code most likely adheres to POSIX. 0 for succes and 1 to 255 for anything else.
It's no where near as pretty as Navi, but here's a Bash function the folks at r/commandline help me with. It queries cheat.sh for examples.
Just make sure curl
is installed and add it to .bash_aliases
# Ask Cheat.sh website for command examples, like: cs lsof function cs() { curl -m 7 "https://cheat.sh/$1"; }
For a version that works with more than one search term (that's magical for programming help) and no matter what your current shell is, run these three commands:
printf '#!/bin/sh\nIFS="+"\ncurl https://cheat.sh/"$*"' > cheat chmod +x cheat sudo mv cheat /usr/local/bin/
Then you can invoke it with something simple like cheat stty
or more complex like cheat bash concatenate strings
. For myself I called it 'ref' rather than 'cheat'. To do that, replace 'cheat' with 'ref' in those commands, everywhere except for the cheat.sh URL.
If you can't or don't want to install cheat
, all cheatsheets are available online. Make an executable file, call it chat
put it on your PATH and add a following line to it:
curl https://cheat.sh/"$1"
Try cht.sh. You can just type something like curl cht.sh/<command>
in your terminal and you'll get a bunch of useful information. Works in the browser too. Basically like a tl;dr for man pages.
https://cheat.sh Interesting tool for developers to get information about any command, programming languages, documents, Q&A.
e.g. To get information about 'ls' command execute this in your terminal:
"curl https://cheat.sh/ls"
e.g. To know about python's append() function:
.. and really cool cmd-line tool is to use cheat.ch -service. For example if you would like to know how to use generators on python you would type:
​
curl '
<code>cheat.sh/python/generators</code>'
​
on your command line. or if you need to know how to convert interger to string in C you would type:
​
curl '
<code>cheat.sh/C/integer</code>to string '