Learning Linux command line

Unless this is for some educational tool which you are planning to create, in my opinion the best way to learn is just to use it.

To do this you need to know enough filesystem manipulation basics to get started, like:

cd change directory like on Windows
mkdir make a directory like Windows' md (I think? been a while since I've used Windows)
rm Delete a file. Arguments -r for recursive, useful for deleting directories, and -f for force.
ls list the contents of the directory, add the argument '-la' to me a bit more useful
df list the 'disk free', ie. how must disk space you have. Add '-h' for human readable numbers on Linux


Your biggest hurdle is likely to be which editor to use. There are essentially two 'manly' editors, 'vi' and 'emacs', which are likely nothing like what you have encountered before - everything is command driven rather than using the mouse.

There are plenty of more basic (and less intimidating) editors, but if you want to really get into the command line (more normally known as the 'shell' in UNIX/Linux), then you could do worse than to try one of them. There are religious wars over which is best - I'll try and be impartial in stating:

vi (or vim - Vi iMproved): Available on every UNIX platform in a basic installation. Very powerful once you get used to the syntax, which can be a bit obscure at times. Also very reliable, in 20 years of using it I don't recall one incident where its crashed.

emacs: Almost an operating system in its own right! More full featured than vi with more language support and plugins. If only I could ever work out how to quit from the damn thing...


Then just decide what you want to do, and with a bit of googling you should be able to get there.
 
The Linux Command Line by William Schotts is a great book.

A Review.

The website

The download

It's a great resource that takes you through just about everything the command line does. I would also recommend you read up on certain terminal applications. Particularly grep, awk and sed which are extremely useful when used together. There are pocket references for all three of those that you should be able to pick up pretty cheaply on the rainforest site. I'm not sure they're available for download under a creative commons license though like the TLCL book.

As for Emacs VS vi... if you want to get into those, you're going to need individual books for each again. There's a joke "emacs is a great operating system, but it could use a better text editor". And "vi is the editor of the beast vi-vi-vi". Personally, on Linux I'm a nano user. EE on FreeBSD. If you want to learn more
 
Take note of whatever useful commands you come across for future reference.

Make sure you fully learn things like grip, find and awk.
 
I would say it's much easier to learn by doing tasks... reading examples and things is okay but to really become proficient you have to be able to map whatever problem you are trying to solve onto the utilities that will be best placed to solve it... (once you get the very basics of the main commands down as described above)

Just come up with things that you know are impractical to do manually... How do I create 100 files called "test_file_XXX" where XXX was replaced by the number 001, 002 etc.. 100... ?

What about if I want each file to contain the text "This is file number X" where X is the number of the file?

Okay now what if I actually wanted all of those files to be called "file_XXX" without the "test_" part, how could I change all of the names (without just regenerating them)?

And so on and so on... Normally when using Linux for your work new problems and challenges will constantly be coming up, but at home with no obvious starting point you have to just try to come up with them yourself. When you're happy that you've got a solution see if you can come up with another one which uses a different set of commands to your first solution (and then decide which is the best/fastest/easiest and why)

If you ever find yourself repeating a near identical set of steps more than 2 or 3 times, there will be a cleverer way of doing whatever it is you're trying to do... so try to work out what it is!

There's a few tips :D Hope they might be helpful
 
Forget vi and emacs. They're great editors, but massively overkill for anyone moving to Linux who just wants to edit a few simple files

nano will give you an editor far more recognisable in how you use it.
 
Unfortunately I'm probably far too set in my ways at this point to switch to vi :p... I can use it enough that if it pops up unexpectedly via some default-editor environment setting and I'm only making a few simple changes I can get by, and I know the command to quit, but that's as far as I want to go!!!
 
The strange thing about VI is that after a few years your hands know how to drive it, but your brain has forgotten. Its the classic interview question, how do you do "x" in VI, or what happens if you type "y" in VI. The danger in asking such a question is that there are usually about 10 answers. Like how do you delete the next character. Well type x or type i<DEL><ESC>. In fact the most useful command is "u", undo what you just did.
 
Forget vi and emacs. They're great editors, but massively overkill for anyone moving to Linux who just wants to edit a few simple files

nano will give you an editor far more recognisable in how you use it.

This seems appropriate:

nwbj8i.png


I use VI but that's only through habit. I've never actually given emacs a go.
 
Another way of getting to know linux is to go through Linux from scratch or install one of the more demanding distros.. Gentoo.. Arch.

I use VI but that's only through habit. I've never actually given emacs a go.
Same here it's just what you get used to I suppose.
 
Love the graphs! XD

To its credit... the graphical version of emacs (i.e. not the "no-window" variant more similar to how vi appears) has quite a lot of standard looking icons and menus and such you can control with the mouse that make picking it up and using it pretty easy

Of course to use it "properly" you really need to learn all the hotkeys and such after which point you don't need those anymore. (One of the first things I did to help learn it was to disable all of the toolbars and menus so I would be forced to use the keyboard for everything - disabled the normal arrow keys as well so I would have to learn the navigation hotkeys)

It's absolutely whatever you get used to though - a lot of the guys I work with use nedit/gedit... quite a lot use kate... plenty of them use IDEs so much of the time they rarely need an all-purpose editor
 
Back
Top Bottom