I made a plain text Linux cheat sheet as a reference and for beginners.
cerium.cc
If you have any suggestions or criticisms, feel free to comment them.
Being plain text, it's much easier to read on a wide screen, or on something without line wrapping.
This is really good. Clear and well laid out.
The only thing that might confuse some beginners is your specific choice of package manager.
I added more information to the installing software section, updated section title to specify Arch Linux, and added another section for Debian and Derivatives.
You're awesome.
Interesting compilation, there is cheat.sh, tldr and others though
I made this just as much for me as I did for others. Writing things down myself really helps me memorize them.
Nice work.
My tiny nitpick is that "touch" will create the file you specify if it doesn't exist. I've seen this usage a lot, so your example may benefit from mentioning it.
TIL βtouchβ has other uses than creating a file
Thanks for all the feedback! I'm much happier with it now, and I'll probably continue to make small changes over time.
I find the references to file extension kinda confusing. Extensions mean a lot less in Linux cli, but I can tell youre just using them for examples. Maybe give more concrete examples instead.
ls *.sh
to list all the files ending in.sh
I updated various examples, and replaced with in most places and removed it from the legend.
I don't know how this would be useful to someone reading the cheat sheet, but here's something interesting I just indirectly found out while skimming it through:
Ctrl+D
does the same thing asENTER
, except the latter additionally sends the end-of-line character to the reader while the former sends nothing;as is the case for shells or interactive programs like the Python REPL,
Ctrl+D
causes them to terminate only because it sends a string that is 0 characters long, and 0-size reads are universally interpreted as files reaching the end.To test this: enter
cat
, type "hello" without pressing enter, thenCtrl+D
: you should see "hellohello".An extremely rare case of this being useful would be using netcat to send a string somewhere, without sending the end-of-line byte at the end.
I updated "Log out" to "Exit (sends a signal indicating the end of a text stream)". Which I think is a lot more accurate, and still easy to understand.
Cool, thank you!
Oh. My. Gosh. I love this. Thank you. And thank you for being
--verbose
about the provenance and history of the document. And big big thank yous for the Internet Archive links. Bravo.would you upload this on github?
Done? I've never uploaded to GitHub before, and I was just doing what I thought I should do. I'll do my best to keep it updated with the version on my website.
https://github.com/ordinarybyte/linux_cheat_sheet
Is there a way to make GitHub automatically detect changes to the file at cerium.cc and update the repo? Or do they not allow that? I know a scheduled script would be able to work but I don't really want to have to run it myself.
Direct link for the lazy
Usually you would go the other way around. Merge changes into git and then distribute from there.
You can do some automation with GitHub Actions, but I have no idea if it can do specifically that
What do you mean about "/ root directory, eg /usr/bin/bash"? / is /, just the top-most directory
Yes, the top most directory, /, is the root directory.
Each directory is a branch in one giant tree structure. For example, if you have a directory containing two other directories, that is a branch that is splitting into two branches. All directories are descendants of the same root.
I added more detail to the description and made a more relevant example. (I think)
I've been using Linux for decades and I bet that'll still come in handy.
cd -
changes to the previous directoryDoes
cd +
work to go forward after usingcd -
?cd -
negatescd -
, so you're right back where you started! It's like multiplying 2 negatives.You might consider putting a license on it
This is fantastic. Just at a glance I already learned something new! Definitely keeping this for reference.
You're a prince among men.
And an Albert among princes.
This is really helpful, thank you.
Aren't
Alt + Backspace
, andAlt + Arrow Key Left/Right
also terminal shortcuts?I like your version, I am bookmarking it.
^S - stop terminal IO
^Q - resume terminal IO (if your terminal looks frozen, this is the one to try)
alt-b, alt-f - jump back/forward one word
This is really nice!
Really cool!
Another good addition to this might be some script rudiments, like how to write and run simple
.sh
filesI owe you bigly
Alt + .
inserts the last argument from the last command run into the current line. I find it helpful all the time.less
can be invoked directly, without having to be piped fromcat
:less
is mostly equivalent tocat | less
I have considered making an alias/function that automatically determines if the file is longer than the terminal, using something like
wc -l
andstty -a | grep -oP "rows \d"
and then either usescat
orless
depending on that... but I already use sharkdp'sbat
, which has that baked in as well as many other conveniencesDon't forget
tail -f
which is kind of likewatch tail
If you're going to have
du
, I would also have a section fordf
, I use the latter more often (but probably because I have like 5 mounts for my OS). Using them in combination is basically what all the gui disk usage analyzers do; something likedf -h
"oh,/var
's almost full" (as previously mentioned, I have different folders on different partitions), thendu -ah /var
and so on to find problem areasThe "installing from source" section works maybe 50% of the time. It assumes a
configure
script, which isn't always the case. I've had a lot of source that comes bundled the way a.deb
does: basically a compressed filesystem that assumes the$CWD
is/
(basically, if you uncompressed it in/
, all the files would go where they needed to be). Sometimes they use language-specific build systems, so you might need go and rust and... Maybe it's best to just keep it your way and look up the rest, but do keep in mind the thing I said about compressed filesystemsfind
is great if you want to reindex everything from square 0; or if you only need to do small directory/tree. If you have the extra space to spare, installlocate
: it indexes the files beforehand (as a cron job) and yields results more quickly for searches that span entire filesystems; the only downside is that you have to manually reindex (sudo updatedb
) to locate files installed the same dayIn the
Extracting, Sorting, and Filtering Data
section, you might consider adding insort -u
anduniq
which fill their own (overlapping) niches.sed
andawk
may be a bit more than beginner, but they are endlessly helpful.tr
can be a useful shorthand for whencut
andsed
don't quitecut
it, but you don't want to build a full in-lineawk
script.Finally:
Should read "Output and errors from are redirected to " because the single
>
overwrites the existing file, as opposed to>>
which, as you noted, appends to the end of the fileA little over a decade & a half and I find that very useful. Should have GPG in for reading signatures on software and such too. If you'd like I can contribute to GPG terminal as I've been using it for a good portion of that time.
Awesome! Thank you kindly
I've needed something like this for a while, thank you buddy
At the end, in redirection,
<<
: that's not how here-documents work. The example gives the impression it will read the given file up until "STOP", but in reality the shell expects you to keep writing your here-doc until you write "STOP" and then feeds it to the program as if it were all on stdin. I don't think wc even does anything with the stdin if you give it a filename... Note that variable expansion will happen in here-docs, so it's a bit different than a simplecat
. Also look into here-strings. And process substitution, I find that quite handy.Great idea. I'll keep this handy from now on.
Wow. I'll definitely avoid Linux now. I had heard Linux was supposed to be easy to use now.
All this terminal stuff is absolutely not necessary for an average user; graphical applications are often more than enough
@ian @asciiandarch If all you do is web browsing, document processing and graphical games you may never ever touch the terminal ;)
It is not as complicated as it looks! As a long time windows user I'm in the process of getting used to the command line and I love the simplicity and direct way of doing things. For some tasks and small programs it is amazing. Grep for example is something amazing that you couldn't do in a windows type UI.
For other stuff like visualizing a directory tree you can always use a mouse interface. You're rarely forced to use the terminal.
Makes as much sense as saying "I'll definitely avoid Windows now. I had heard that Windows was supposed to be easy to use", since most of this also applies to WSL2.
Maybe the guide is not intended for some beginners after all?
I suppose. If your criticism is that it could have been more specific as to what you are a supposed "beginner" in, then I agree.