Update 25 Sep 2019: This article is now available in Japanese, thanks to the hard work of ラナ・クアール. Please check out their work by following the li...
For further actions, you may consider blocking this person and/or reporting abuse
Holy cow!
My Markdown editor started choking near the end of writing this. RIP Simplenote.
That's what s..... ah nevermind 😛
this is an awesome post but I've no idea how could anyone use a shell that looks like a pipe operator all the time ... some command with pipe reads very badly, why not removing all the starting parts of your snippets, adding a classic
$
like any other shell, instead of17:40 | andrew@pc01 ~ |
?Fabulous readable reference, thanks Andrew!
Minor niggle - almost all of these are not bash commands, but command line tools that work the same from any shell - it would be nice to know what are bash built-ins that might go pop in another shell, and what aren't :)
Long-running advanced voodoo:
I prefer screen over using disown, because of the reconnection ability.
I'd like to add tmux to this list of helpful tools. Does similar thing as
screen
.Thanks, Phil! I'll have to do some more research.
Watch out for the "unabridged" version of this in the future.
Yes, I was missing those on the SSH section, @andrew really awesome post
FWIW, most of these aren't actually
bash
commands (only the builtins are); they're Unix/Posix/whatever commands.Also, the prompt you use confuses me: it looks like there's an extra command (such as the ex command) at the start of the pipeline.
Great reference, I would suggest changing the format of your prompt. Having the | symbol dividing the time and username is confusing on first look.
Great list!! I would have added "type" and "tmux" to the list :)
For folks interested in useful Unix tricks, Unix Power Tools book is a great source.
Impressive post! I remember when I found ncdu it was an amazing day. It's by far my favorite tool to find what's taking up my disk space! I really hope more people use it as a result of your excellent post!
ncdu
is great, it's whatdu
should have been. Writing this post, I found a few other commands and flags that I forgot about / never learned about. One of my favourite ones is the-p
flag tomkdir
, which will create all missing intermediate directories! Small things like that can save you lots of time.I think it's really awesome that you tought of the reader and added a "Back to TOC" after each topic for easy navigation!
And of course the content is very well explained with just enough words but much information in it :)
Cool article but there are few things I need to disagree.
Environment variable creation
Using format
foo=bar
stores environment variable only current command. To keep environment variable loaded in your running bash process you need to export it withexport foo=bar
. This behaviour can be checked with commands env, printenv or by echoing environment variable.source vs sh
Results of source and sh commands might look identical but they are not. Source command executes script in running bash and all exported envirenment variables are part of the running bash shell. sh invokes a new shell and exported variables are not usable in the calling shell. Also working directory of calling bash shell might be changed when using source command.
Please note that sh usually is linked to posh or some other lightweight shell which does not have all bash features.
More about source
In some systems source and . are interchangeable command. (POSIX compatibility is swamp)
Anyway source command is good if you need (temporary) setup your environment: e.g. load environment variables, aliases and even request passwords from user with
read -s <variable_name>
or to load functions from external libraries.Usually source is used in scripts(1) but I'm sure that users can find use cases when to use source to setup environment for running shell.
Good post! Do not run kill -9, but rather use just plain kill, or kill -15 if that doesn't work.
Kill and kill -15 end a process somewhat gracefully, so that the os is at least notified that the process is killed. -9 just causes it to vanish with no notice. It's akin to just hitting the power button, on a process level, without doing any sort of shutdown routine.
Also, ag (Silversurfer) is my team's grep replacement, give it a look.
Exactly what I need right now...
Actually, more than I need, but in the best way, haha. Thx! 😄
Great article!! Thank you so much for the contribution!👏👏
Btw, the exercise about
nohup yes
just almost broke my PC by creating a file of 40GB in less than a min!!🫣😱This is because nohup created a log file called nohup.out appending all output values spit by the command. So in very little time I had a HUGE file with 'y' on each line.
I advise you to change this exercise before brake others computer storage : )
A great resource, thanks.
If the file you're looking for is not found with locate, you can run updatedb to update the list of files for locate.
This tutorial means that this is a brief introductory guide to SED that will help give beginners a solid foundation about concrete tasks.
letsfindcourse.com/tutorials/sed-t...
Thank you for your impressive post!
And for mac users: If you want to use the very convenient ncdu command, there's a version available for Homebrew:
brew install ncdu
rm -rf
is commonly referred to as "rimraf" or "rimraf-ing".Looking back it seems intutuitive but I didn't make that connection for the longest time.
Great article :)
Great post!
BTW, A similarly "for beginners" tutorial that I enjoyed, in book form, is M.G. Venkateshmurthy's "Introduction to Unix and Shell Programming," if anyone is still looking for additional material. (It gives fun "why" context to all of its "how" -- for example, it points out that the commands/flags of command-line interfaces are short and hard to remember because back when the only way to interact with your computer was a command line interface and only specialists used computers, the last thing programmers wanted to do was type a lot, so they just made up a bunch of cryptic short commands.)
WELL DONE!
set -x is a favorite of mine for debugging.
#!/bin/bash
set -x
this turns on line-by-line logic/command flow output and is great for debugging. It can be used inside a script or on the command line. If using on the command line, you'll want to turn it off at the end of the line. When used in a script, it's activity ends when the script does, or when unset with set -x
Thank You for sharing such an informative post. I like the way you present the things and make the post more presentable. At PegaLogics, You will get the best industry-leading experience in the field of Mobile App Development & Web Designing. Visit our website, Regards- pegalogics.com/services/web-design...
Thank you for writing this post!
Hi everyone!
Thanks for the amazing response to this article! I've updated the command prompt so it's a bit less confusing. I hope to post an updated / revised / expanded version of this in the future, where I'll take everyone's suggestions below into consideration.
Thanks again!
the picture associated with the
xdg-open
command appears to be from a Windows machine! how would it be possible?Hi Amr,
Because I'm
ssh
ing into an Ubuntu machine from Windows using MobaXTerm.xdg-open
(at least in this case) is using the default window styling from Windows.Good article. Should have mentioned ipython and trash-cli though. (Also probably in most contexts, for the Python 3 version to run, one has to enter in "python3", "ipython3", "pip3" etc.)
This is so good. I can use many of these.
Thanks for sharing!!
Very useful article. Thanks Andrew for this article.
Awesome post!!! Thanks Andrew.
Really remarkable article!
But it seems that
top
uses the capital-U
for the username. At least on Mac OS and FreeBSD.You meant
du
there, I think.I did, thanks! It's fixed now.
Bonus tip for date command:
date +%s
prints unix time (in seconds)Nice reference, thanks!
Wohoo awesome, thanks!
sick post! need these
Great. But that Pipe operator as prompt in the command snippet seems very confusing.
Epic.
Thank you, Andrew.
A great article written at the perfect time (I started using Ubuntu recently) 👍
Amazing article, got to learn many new thing :)
Sweet Jesus, this is awesome!
I took note of some of these, can't wait to show off in front of my peeps back at the office.
WoW
This post is a great effort to cover most cli commands.It can help many to get started with command line.
Awesome stuff Andrew! Funnily enough I missed the title (and the URL ...) and was pleasantly suprised by how many different commands you listed. Nice work
Thanks Andrew
I will use this, thanks! Now, if posts a similar article for PowerShell, I'll be done. lol
That's a monster post!
This is an awesome list - but it should be noted that most of these are not bash commands. They are just common programs. Many of them are therefore usable in any shell, not just bash.
Great list! Thanks for sharing.
Hello
Can I add the link to this cheat sheet in my compilation?
The ultimate Cheat sheets compilation (200+) - 🔥🎁 / Roadmap to dev 🚀
DevLorenzo ・ Mar 2 ・ 15 min read
Thanks for the awesome list!
This is really good post! Everyone that is interested in Linux should save it and revisit it once in a while! Great content!
This is very long 😐
Your article is valuable to me and to others. Thank you for sharing your information for my new blogging website teqhow.com!
hard links vs soft links is best answered here askubuntu.com/questions/108771/wha... nice post!
awesome, keep it up
Great article! 🙌
You should check out this Open-Source Introduction to Bash Scripting Ebook on GitHub as well!