Best way to learn CLI?

For a long time I have had quite a few linux systems installed in my house, a majority running some variation of Ubuntu LTS. For the duration of my experience with linux I have stuck to the GUI and am now looking to learn how to (almost) entirely operate the OS in BASH. Any books or other resources anyone can point me to? Any tips? Right now I am reading "Command Line Crashcourse" but have a feeling it doesn't go as much into depth as I would like to. In the near future I would like to get to the skill level to operate an SFTP server headless through remote access, thanks.

http://www.gnu.org/software/bash/manual/bashref.html (you definitely don't need all of that but there's some useful stuff there)

Manpages. Find out how the searchfunction works in manpages, it's a timesaver.

Knowing the commands you need to use (through using them and reading the manpages). The more you use them the more natural they come to you (and you'll remember them better).

You don't need to know all that much for just operating a SFTP server really. I think SFTP uses telnet? In which case you'll need to learn how to telnet to it. Anyway, whatever method SFTP uses to let you communicate with it, you'll have to learn it. But tbh once you've set it up and got it running I personally see no point in having to communicate with the sftp process/program unless you're doing a public one.

First and foremost you have to accept that if you have no experience with cli so far, when facing cli you will feel like an illterate child trying to read all over again.

Ok mabye not exactly ;)

Despite the fact I used Linux like 10 years ago for short amounts of time I mostly learned all my current Linux CLI skills in the past 2 years during my apprenticeship to become an IT specialist for system integration/administration (beware of the german term: Fachinformatiker für Systemintegration) at a small ISP.

The biggest problem I had in the beginning was a lack of knowledge about basic commands to move through the filesystem and its structure, get information and change stuff.

This comes down to really a just bunch of commands that are very easy to learn and will stick with your memory very fast and the better the more often/regularly you use them.

Instead of only starting with literature I would recommend: go straight to your shell and try to get some impressions where "stuff" is located. First problem: how you get to another directery? that one is simple: cd = change directory

i.e.: cd ~

will take you to your users home directory

Then take a look at the files and directories. That one is: ls

i.e.: ls

output will be a table of files and folders that are in the current directory. There are additional arguments to this command in order to for example show hidden files, give output as a list with assigned rights, show human readable file sizes and more.

Note: paths in unix like systems use the forward slash / not the backslash \ windows uses.

With cd and ls you can already explore most of your filesystem and the structure of linux.

A good starting point is your home directory that contains most of the files that are specific to your current user. When sudoing or being root look at what the root directory has to offer you. You will find directories like etc, var, tmp, root, users, proc of which you dont have to understand all at this point.

Next I would start adding some literature to your experiments. Quick google search revealed: http://linuxcommand.org/learning_the_shell.php which makes a promising look to me for a beginner. Also it has a nice interoduction :).

Soon you will be confronted with more commands and programs, like chmod (modify rights of a file), chown (change owner of a file), vi / vim / nano (cli text editor). apt-get / yum / ... (OS integrated package manager), df (show free disk space), du (show disk space used at a given path), cat (output file contents), less (view file content without flooding standard output), mkdir (that on might be obvious :P ) and some (potentially many)  more.

For almost all commands and programs you will find a manual which you can open via the command "man".

i.e.: man ls

will show you the syntax and possibilities of ls. fun fact: you can also use "man man" :)

After doing the stuff above and having acquired the basic skills to move through the filesystem you can think about a program you want to install. In the beginning it's the easiest to use the packet manager of your linux distro which is apt-get for ubuntu.

After that try something like a teamspeak server or ftp server (or whatever else) to that does not come through the package manager. Thats the point at which you will need a http downloader (e.g. wget) an unpacking program (e.g. unzip or tar) and knowledge about execution rights, script-execution and some of the aforementioned filesystem-structure-proficiency (ooh that sounds tough^^).

 

p.s.: that's only my sort-of-spontaneous go on this. feel free to correct or complement things.

Thanks, I will look into that.

Just a couple of tips for command line use:

  • Typing a letter or sequence of letters and hitting <tab> <tab> will list the available commands that start with that letter/sequence.
  • As others have said, man pages are your friend when using new commands. (combine with random commands you see from a <tab> <tab> to learn about tools you may have not known existed.)
  • Always double/triple check paths when using dd, rm -rf or any other tool that can seriously screw things up. ex -> "sudo dd if=foo.iso of=/dev/sda" may overwrite your hard drive with information from "foo.iso" if your hard drive is /dev/sda. (however, you hard drive may not be /dev/sda "mount" should show you all your mount points (/dev/***))
  • Off the top of my head some interesting and useful commands/tools are: ls, cd, dd, rm, gzip, ssh, top, nano, elinks, ifconfig, netstat, lsof (-i), grep and less.

Check out this link http://lifehacker.com/5622340/who-needs-a-mouse-learn-to-use-the-command-line-for-almost-anything . Start By learning to do the things you already do, but from a terminal... I have an old post here in the forum where I logged is read the forums and posted with Elinks from a machine without X. Marvel at what happens if you press Ctrl+Alt+(F1-F6). Little by little you will start to prefer the command line for certain things and having a terminal window open all the time will seem as necessary as having a mouse.