I came to answer your question and say that when I started computing there was only the command line - there were no windows, effectively no graphics, and the only thing you could do was type commands.
But then you ask if there are tutorials, and that I can't help you with. Having said that, I tried this search:
What he said. It seemed a good idea at the time, considering that, back then, the alternative to a CLI on a 80x24 monochrome terminal were decks of punch cards, featuring 30-60 minutes turnaround time, with output on greenbar paper.
Besides, VMS had a pretty nice "help" command. Barely had to crack open any of the orange binders in the 10 feet or so shelf of manuals.
(For entertainment purposes only. Do not attempt this at home. Get off my lawn ;-)
Me too, that's all there was. And that may be the answer: only allow yourself the command line for longer and longer periods of time. Force yourself to learn it.
(The first '$' is your command line prompt, yours may differ; you don't type that. The other '$' characters you do type.)
Now run each command from the inside out, starting with the man command. See what each command does. Build it up bit by bit, that's exactly what I did, like this:
- the man command
- the man command piped into the cut command
- the man command piped into the cut command after reading "man cut" to remember about the --delimiter option
- the output of that pipeline fed to which
- the output of which fed to file
Note that I didn't use any for loops or variables, the shell did the right thing for me.
Read the man pages for each of those commands.
set -o vi or set -o emacs (or their equivalent in .inputrc) helps a lot when you compose things incrementally. esc-k k k (etc) is your friend if you set -o vi.
Read man bash. It will take you a long time. For today, read the section on READLINE. While in man bash, search for the word READLINE at the front of the line, like this:
/^READLINE
Slash = search
^ = anchor the search to the front of the line
READLINE = what you're searching for in the current man page.
For now, all you need in your ~/.inputrc file is:
set editing-mode vi
This will give you vi command line editing in bash, as well as any other program that uses readline, like the python REPL.
For more info on .inputrc,
$ man readline
which is documentation for the C interface to readline, but is mostly about how readline is used by a user. For example, in man readline
/VI Mode bindings
gives you all your command line editing commands when you use vi mode.
Get a mostly table of contents of man bash, for your searching pleasure:
I am not a command line pro either but whatever limited experience i have came from working from mercurial and from college unix lectures. I would suggest you incorporate command line in some of your routine work (source control for example).
I think I first got into it when I was trying to get some sort of video to play in QuickTime - since then I've switched to VLC, cause I didn't have much luck.
Then I started doing Learn Python the Hard Way, which taught me the easy stuff like ls, cd, rm, and so on. Then I had a course in Linux Systems Administration, where I had no choice but to master it as fast as possible.
I started in DOS watching over my brother's shoulder. (There was no GUI back then.) I used to make batch files and such.
Eventually I grew to love bash. I am sure there are plenty of keyboard shortcuts I don't know, but I find using the command line to be quicker than any other form of communicating with the computer.
I use keyboard shortcuts in Firefox, and occasionally dream of an Awesome Bar that works like bash.
I also really like using the 'move-cursor-a-word-left/right' and 'move-cursor-to-end/beginning-of-line' and 'move-cursor-to-top/bottom-of-textarea' functions you can find in almost every GUI.
Finally, I use Spotlight to load all my applications: I hit cmd-space and then it's usually 1 key to load my most commonly used applications, and generally 3-4 in worst case.
My suggestion: use the Terminal for everything: Learn to edit text files in emacs or vi, use a command line SQL browser, do source control from the command line, and learn sed, awk, and cut (plenty of tutorials out there). Use the keyboard in the browser and in GUI textareas as much as possible.
Finally, shameless self-plug, I have been using this simple piece of code every day for a couple of years, a command-line (tab-completed) notebook for bash: https://github.com/nchelluri/notes .
HTH.
Edit: I keep looking at this page every few months, but it never seems to be compatible with my version of Firefox: http://paulrouget.com/e/jsterm/ :(
>I use keyboard shortcuts in Firefox, and occasionally dream of an Awesome Bar that works like bash.
This reminded me to check up on Ubiquity[1]. Mozilla doesn't even host a page for it anymore, but apparently someone adopted it[2]. I'm going to have to play around with this tomorrow; I'll be happy if it's half as useful as I remember.
I started with DOS 4.01, and a DOS manual. I went command by command, until I got to format "hey, we have a lot of files, it would be nice to have them formatted..."
Once upon a time (c. 1990-1997), most programs were written for DOS, and some amount of command line knowledge was required to run them.
Installers were typically batch files (the DOS equivalent of shell scripts), which was really cool: You could see exactly what they were doing [1], and you could improve your command-line-fu by seeing the techniques people used [2].
[1] Usually it was just copying the application files from directory to directory. Nowadays installers generally muck with the Registry, C:\Progra~1 [3], C:\Users\Applic~1 [3], the Desktop (who knows where that is), the Start Menu, and the Windows equivalent of /etc/init.d (I remember there are several of them, and your system will get slower...and...slow...er...if you don't clean them out regularly)
[2] Like environment variables or @ECHO OFF.
[3] Spaces in filenames need to die. Whenever possible I use the 8-character names Windows generates for backwards compatibility with DOS.
I learned the command line by using the command line. When I switched to Arch Linux, using bash was inevitable. It took many Google queries and reading many man pages to finally become comfortable in it.
Experimentation is another good option, and goes a long way, but it can be scary. If you're at all worried about doing permanent damage, install a virtual machine (i.e. VirtualBox + the server version of Ubuntu or whatever OS you want). That way you can experiment away without fear of doing permanent damage. If it happens just trash the the VM and start again.
The best way to learn is by doing and using it often.
Don't read, use it often!
There must be a strong reason to learn, and don't just learn for the sake of learning!
I have been using Linux daily, its around 5+ yrs. I play around with numerous VPS remote boxes and still I'm learning, but everyday getting better at it.
This way, it should only get better and better over time! The more you use in your daily workflows, the more you appreciate and understand the internals too.
And there are no other shortcuts to learn command line tools.
Courses or short tutorials won't help much.
You have to involve command line tools in your daily workflow's. Its a long term process, so keep learning, improving and don't ever stop!
I was on a gigantic Sequent machine with hundreds of users at UIUC.
When I got my account, I given a user agreement paper with rules and regulations that, at the very bottom, had a dozen or so commands on it. There were some very terse and cryptic descriptions. ("cd: change directory; man: read a manual page; ps: print running processes; grep: search for a string")
Eventually I bootstrapped my way up to doing "ps -augx" to see what other people were running. Then I would try whatever they were doing.
Exactly the same for me, before I could read, write or speak english. My dad gave me a list of commands.
It was a bit hard to get out of the station in police quest and only years later did I understand why my dad didn't want to help me to get into this game where a "man" is floating from left to right and you need to answer a question to play.
I dont know about other people, but I learned based upon need. I needed to be able to manage files so I learned cd,mv,cp,ls. Then I needed to write the output to files so I learned about piping and the redirect operator. Then I needed to search through the output so I learned grep, etc.
My Windows laptop was outta commission for a few weeks in college. I could use the public computer labs to do my homework, but the only way I could do any programming was to SSH into remote UNIX boxes that I had access to and write the code directly on the server. (I was doing mostly PHP development at the time, and had laboriously setup PHP/Apache/MySQL on my Windows box until it died.) When your only window into the world is an SSH terminal, you pick up the command line and vim fairly quickly.
In 1997, a friend of mine came to visit, installed Debian 2.0 on my 486 with a unsupported Intel i740 videocard, showed me how to log in, 'man -k <something>' and 'man man', then said "See ya next week, have fun". And I had.
Ultimately, the best and proper way to be a console master is to install a Unix distribution on your one and only everyday machine and avoid any sorts of X or Window manager at all.
These are useful when you have a specific task you want to get done, not so much otherwise. Therefore,
(3) Try to do things at the command line that you would normally do via mouse. If you have no idea how, google or 'apropos'. If you learn of a tool and have no idea how to use it, google more or 'man'.
(3a) Do the simple stuff via the CLI--removing and moving files, examining directory contents, et cetera. (Be careful with rm! It will not warn you by default.)
(3b) More complex stuff too--try editing text with a terminal editor. Many people swear by emacs and vim. They have learning curves of their own but they are worth it. Pick one.
(4) Pipes and input redirection. Send the output of one command as the input to another, send the output to a file, etc. This is where your standard Unix shell gets really powerful.
The first computer my family owned was an IBM PC XT, which was my introduction to the concept of a command line interface being normal. I do wonder what it'll be like for the generation of potential hacker types who won't even remember a world before slick iOS UIs and ubiquitous internet in your pocket. Computers were a kind of source of wonder for me in my childhood, and what I see from young children today is they view them as very mundane, which I suspect hurts their curiosity.
Years detached from those experiences with the XT, I picked up Linux in the late 90s. It was a bit of a learning curve from DOS. But I picked up some very dated book at the local library about Unix and it kind of set me straight.
The real revolution in my thinking came in 2001, when I was unfortunate enough to buy a motherboard with an ALI 1647 chipset (it's sad that I have brain cells devoted to remembering that model number). That chipset, when combined with an NVIDIA video card, would make X crash and lock up after about 30 minutes of use (before you start bashing on Linux, I'd been told the same thing would happen on Windows with this hardware combination). For six months months I was in denial of this problem. I kept thinking the next BIOS update or the next driver would fix the problem. In the meantime I used nothing but console mode, because it was the only thing that was stable.
Six months or so later I sold the old motherboard, paid my quarter to get myself a "real motherboard" (ok, it was more like USD$200), and got X working again. It was good and all to have a GUI again but one thing I did notice was that my command line skills were much improved.
58 comments
[ 2.9 ms ] story [ 140 ms ] threadBut then you ask if there are tutorials, and that I can't help you with. Having said that, I tried this search:
http://www.google.co.uk/search?q=command+line+tutorial
and I got lots of hits, including these:
* http://www.davidbaumgold.com/tutorials/command-line/
* http://stackoverflow.com/questions/8170/best-windows-command...
* http://www.tuxfiles.org/linuxhelp/cli.html
I'm not a beginner on the command line, so I can't assess how well they meet your needs.
Besides, VMS had a pretty nice "help" command. Barely had to crack open any of the orange binders in the 10 feet or so shelf of manuals.
(For entertainment purposes only. Do not attempt this at home. Get off my lawn ;-)
I really like this book, even today: http://shop.oreilly.com/product/9780596003302.do
The key to being proficient at the command line (as distinct from writing shell scripts) is to think of it as composition.
For example, run this:
(The first '$' is your command line prompt, yours may differ; you don't type that. The other '$' characters you do type.)Now run each command from the inside out, starting with the man command. See what each command does. Build it up bit by bit, that's exactly what I did, like this:
- the man command
- the man command piped into the cut command
- the man command piped into the cut command after reading "man cut" to remember about the --delimiter option
- the output of that pipeline fed to which
- the output of which fed to file
Note that I didn't use any for loops or variables, the shell did the right thing for me.
Read the man pages for each of those commands.
set -o vi or set -o emacs (or their equivalent in .inputrc) helps a lot when you compose things incrementally. esc-k k k (etc) is your friend if you set -o vi.
Read man bash. It will take you a long time. For today, read the section on READLINE. While in man bash, search for the word READLINE at the front of the line, like this:
/^READLINE
Slash = search
^ = anchor the search to the front of the line
READLINE = what you're searching for in the current man page.
For now, all you need in your ~/.inputrc file is:
set editing-mode vi
This will give you vi command line editing in bash, as well as any other program that uses readline, like the python REPL.
For more info on .inputrc,
which is documentation for the C interface to readline, but is mostly about how readline is used by a user. For example, in man readline/VI Mode bindings
gives you all your command line editing commands when you use vi mode.
Get a mostly table of contents of man bash, for your searching pleasure:
Sort it:I realized/remembered while reading the other comments that knowing what's available is a necessary part of "just use the command line a lot."
So try this, to get a good list of what's available (and for more command line composition)
See if you can figure out what 2>&1 does (it's a very common idiom, probably easy to find), and figure out why it's needed here.That's a long list of stuff, look at it a page at a time:
That's still a lot of stuff, save it off in a file in your home directory for later:[1] http://www.gentoo.org/
Then I started doing Learn Python the Hard Way, which taught me the easy stuff like ls, cd, rm, and so on. Then I had a course in Linux Systems Administration, where I had no choice but to master it as fast as possible.
Eventually I grew to love bash. I am sure there are plenty of keyboard shortcuts I don't know, but I find using the command line to be quicker than any other form of communicating with the computer.
I use keyboard shortcuts in Firefox, and occasionally dream of an Awesome Bar that works like bash.
I also really like using the 'move-cursor-a-word-left/right' and 'move-cursor-to-end/beginning-of-line' and 'move-cursor-to-top/bottom-of-textarea' functions you can find in almost every GUI.
Finally, I use Spotlight to load all my applications: I hit cmd-space and then it's usually 1 key to load my most commonly used applications, and generally 3-4 in worst case.
My suggestion: use the Terminal for everything: Learn to edit text files in emacs or vi, use a command line SQL browser, do source control from the command line, and learn sed, awk, and cut (plenty of tutorials out there). Use the keyboard in the browser and in GUI textareas as much as possible.
Here is a neat site which has turned up in a few of my Google searches: http://www.commandlinefu.com/commands/browse
Finally, shameless self-plug, I have been using this simple piece of code every day for a couple of years, a command-line (tab-completed) notebook for bash: https://github.com/nchelluri/notes .
HTH.
Edit: I keep looking at this page every few months, but it never seems to be compatible with my version of Firefox: http://paulrouget.com/e/jsterm/ :(
This reminded me to check up on Ubiquity[1]. Mozilla doesn't even host a page for it anymore, but apparently someone adopted it[2]. I'm going to have to play around with this tomorrow; I'll be happy if it's half as useful as I remember.
[1]: https://en.wikipedia.org/wiki/Ubiquity_%28Firefox%29 [2]: https://bitbucket.org/satyr/ubiquity/overview
I could also recommend TUPE[1], it teaches you how to effectively use the command line and write shell scripts.
1. The Unix Programming Environment by Brian Kernighan and Rob Pike.
That day I learned about OS installation as well.
And then continued.
Installers were typically batch files (the DOS equivalent of shell scripts), which was really cool: You could see exactly what they were doing [1], and you could improve your command-line-fu by seeing the techniques people used [2].
[1] Usually it was just copying the application files from directory to directory. Nowadays installers generally muck with the Registry, C:\Progra~1 [3], C:\Users\Applic~1 [3], the Desktop (who knows where that is), the Start Menu, and the Windows equivalent of /etc/init.d (I remember there are several of them, and your system will get slower...and...slow...er...if you don't clean them out regularly)
[2] Like environment variables or @ECHO OFF.
[3] Spaces in filenames need to die. Whenever possible I use the 8-character names Windows generates for backwards compatibility with DOS.
https://peepcode.com/products/meet-the-command-line
https://peepcode.com/products/advanced-command-line
Experimentation is another good option, and goes a long way, but it can be scary. If you're at all worried about doing permanent damage, install a virtual machine (i.e. VirtualBox + the server version of Ubuntu or whatever OS you want). That way you can experiment away without fear of doing permanent damage. If it happens just trash the the VM and start again.
Don't read, use it often!
There must be a strong reason to learn, and don't just learn for the sake of learning!
I have been using Linux daily, its around 5+ yrs. I play around with numerous VPS remote boxes and still I'm learning, but everyday getting better at it.
This way, it should only get better and better over time! The more you use in your daily workflows, the more you appreciate and understand the internals too.
And there are no other shortcuts to learn command line tools. Courses or short tutorials won't help much.
You have to involve command line tools in your daily workflow's. Its a long term process, so keep learning, improving and don't ever stop!
When I got my account, I given a user agreement paper with rules and regulations that, at the very bottom, had a dozen or so commands on it. There were some very terse and cryptic descriptions. ("cd: change directory; man: read a manual page; ps: print running processes; grep: search for a string")
Eventually I bootstrapped my way up to doing "ps -augx" to see what other people were running. Then I would try whatever they were doing.
It was a bit hard to get out of the station in police quest and only years later did I understand why my dad didn't want to help me to get into this game where a "man" is floating from left to right and you need to answer a question to play.
In 1997, a friend of mine came to visit, installed Debian 2.0 on my 486 with a unsupported Intel i740 videocard, showed me how to log in, 'man -k <something>' and 'man man', then said "See ya next week, have fun". And I had.
(1) At the terminal, via
or and (2) online by googling.These are useful when you have a specific task you want to get done, not so much otherwise. Therefore,
(3) Try to do things at the command line that you would normally do via mouse. If you have no idea how, google or 'apropos'. If you learn of a tool and have no idea how to use it, google more or 'man'.
(3a) Do the simple stuff via the CLI--removing and moving files, examining directory contents, et cetera. (Be careful with rm! It will not warn you by default.)
(3b) More complex stuff too--try editing text with a terminal editor. Many people swear by emacs and vim. They have learning curves of their own but they are worth it. Pick one.
(4) Pipes and input redirection. Send the output of one command as the input to another, send the output to a file, etc. This is where your standard Unix shell gets really powerful.
Turns out it's a synonym for "man -k".
Years detached from those experiences with the XT, I picked up Linux in the late 90s. It was a bit of a learning curve from DOS. But I picked up some very dated book at the local library about Unix and it kind of set me straight.
The real revolution in my thinking came in 2001, when I was unfortunate enough to buy a motherboard with an ALI 1647 chipset (it's sad that I have brain cells devoted to remembering that model number). That chipset, when combined with an NVIDIA video card, would make X crash and lock up after about 30 minutes of use (before you start bashing on Linux, I'd been told the same thing would happen on Windows with this hardware combination). For six months months I was in denial of this problem. I kept thinking the next BIOS update or the next driver would fix the problem. In the meantime I used nothing but console mode, because it was the only thing that was stable.
Six months or so later I sold the old motherboard, paid my quarter to get myself a "real motherboard" (ok, it was more like USD$200), and got X working again. It was good and all to have a GUI again but one thing I did notice was that my command line skills were much improved.