Linux Command Line Cheat Sheet
Linux Command Line Cheat Sheet
LOGIN or REGISTER
-Q Quoted output
Bash Shortcuts Search Files Nano Shortcuts
cmd 1>&2
cmd 2>&1
Pipes
cmd1 | cmd2
cmd1 ; cmd2
cmd1 || cmd2
cmd &
sysadmin shell
PDF (recommended)
PDF (2 pages)
Alternative Downloads
2 Pages
Comments Created By
Thanks for creating this cheat-sheet Dave. The one thing I missed was
"grep -o"; Show only the part of a matching line that matches PATTERN
Metadata
I've added "grep -o" to the cheat sheet :)
Languages: English
The I/O redirection section could use "2>" and "&>" examples, I always 2020
Favourited By
DaveChild, 10:02 28 Nov 11
Good idea - I'll add that (once I remember how they work myself
... :) )
Ah, Q&A means I would be able to cheat with it and use it for
two column with an extra line. Thanks for the info.
On the redirects, the one I most commonly use is ignoring errors (2>/dev
/null, or more succinctly 2>&- ).
For example, if I'm looking for files and I don't care that I haven't access to
parts of the filesystem, we might do something like:
I think the "Bash Shortcuts" part is a little misleading. The "ctrl-a", "ctrl-e",
"ctrl-k" is in emacs mode. But there should be many people preferring vim-
mode or some thing like that.
Davis Peng 13:57 22 Mar 12
Thanks a lot for your sheet, I just need such a linux command summary
such as this sheet.
Hi,
Thanks
I'd just like to point out a trick I use with the head and tail commands:
First, you can designate the number of lines to return, like so: head -100
filename
I often use both head and tail together to get a section of a file by piping the
output of one into the other. The following command gets 100 lines, starting
1000 lines before the end of the file:
tail -1000 filename | head -100
You could, of course, reverse the commands to get a section near the top of
the file. To get lines 91-100:
head -100 filename | tail -10
I just wanted to take a moment to thank you for putting this together. This is
a big help to me I am new to OpenFiler witch I believe uses bash at the core
so I am of course new to Linux. I didn't really think it would be quite so
difficult to find resources that one can use to navigate the command line but
I guess most folks use the GUI. But, I'm not most folks when I bought my
first IBM 8088 I started with DOS.Anyway, thanks for the time and effort you
put into this, sorry about digressing there.
Excellent Stuff man.. I think these are the most commonly used commands..
Good Effort.
you need to figure out how to split your command sheet as a pdf
top
CTRL-Z
ps aux | grep top
fg
However, I don't like the "chmod" commands you are using. I don't think
anybody should use the numeric version of chmod anymore. Your example
"chmod -R 600 folder", is the best way to lock yourself out of your own folder
and loose any executable bits on the scripts. I would rather use the symbolic
version:
chmod -R u+rw folder # Add read-write for user on all files in folder
chmod -R og-rwx # Remove read write and execute bits for "other" and
"group" on all files in folder
chmod -R og=u-w folder # Give other and group the same rights as user, but
removing writing rights.
I would also add the tar command. No sysadmin would survive without it.
To create archive
tar cvzf archive.tar.gz /file_or_folder/to/archive
Great resource - thanks for taking the time and trouble to put this out there.
My favorite ls options are '-ltr' . The t sorts files by time, and r reverses that,
so newest files show up right above the prompt, no matter how long the
listing is.
What about CTRL+y to paste the stuff you cut back in? How can you leave
that out? CTRL+a/e and CTRL+u/y are the pairs I remember.
Or if the PDF at least split into 2 pages (so it could be a laminated 2-sided
sheet) without cutting commands in half.
This is bash-tastic!
Good job on the cheatsheet - this will definitely come in handy for my Linux
exam next week. Some commands on umask would be a good addition to
this cheatsheet :).
Bill 17:30 17 Feb 14
Hi, handy sheet. Just one thing. Find will do a recursive search by default. In
the find /dir -name name* should be in double quotes if you want it to
recursively find all files starting with name:
That's because, without the quotes, the shell will expand the wildcard before
handing the parameters to find. To unexpected things might happen if you
don't have the quotes. Please see the examples below:
$ find .
.
./name1
./name2
./dir1
./dir1/name3
./dir1/name1
./dir1/test3
./test1
$ find . -name name*
find: paths must precede expression: name2
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec]
[path...] [expression]
$ find . -name "name*"
./name1
./name2
./dir1/name3
./dir1/name1
$ touch dir1/fred1
$ find .
.
./name1
./name2
./dir1
./dir1/name3
./dir1/name1
./dir1/test3
./dir1/fred1
./test1
$ find . -name name*
find: paths must precede expression: name2
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec]
[path...] [expression]
$ find . -name "name*"
./name1
./name2
./dir1/name3
./dir1/name1
$ find . -name fred*
./dir1/fred1
$ find . -name "fred*"
./dir1/fred1
$
grep -B#
This shows what you are searching plus additional lines where number is
added. Great for DHCP lease searching.
Great reference!
The section on Screen is missing "Ctrl-A d" for detaching.
jt 12:38 22 Jul 15
DF 08:31 25 Aug 15
'echo $SHELL' actually prints the default shell, 'ps -p $$' will print the current
shell
Alternatively, change all the green texts to black and keep the backgrounds
green?
Hey GloObi, thanks for the heads up about the broken download
button on this cheatsheet. We'll get it fixed and I'll let you know
when its been done. Have a great day.
Hi GloObi,
This is now fixed. Please let me know if you have any more
problems.
Nat
Hi d.falkovsky,
Nat
I think the colour pdf link directs back to the original page
All links for download are dead, pleas fix this issue ASAP. Would be greatly
appreciated, thanks.
thanks Dave
besides ^w my most used nano commands:
Alt+Space Go back one word
Ctrl+Space Go forward one word
Add a Comment
Your Comment
Your Name
Your Email
Address
Your Comment
Regular Expressions
Cheat Sheet CSS2 Cheat Sheet mod_rewrite Cheat Sheet
Cocobaby927 published
Cheatography Anatomy and Physiology-
Urinary System.
2 days 7 hours ago
© 2011 - 2023 Cheatography.com | CC License | Terms | Privacy Latest Cheat Sheets RSS Feed