TechSpot

How-To: A Beginner's Guide to the Linux Command Line

  1. misor likes this.
  2. Siavash

    Siavash TS Member Posts: 48   +12

    Great article, thank you very much! :)
     
  3. EClyde

    EClyde TS Enthusiast Posts: 178   +22

  4. Alpha Gamer

    Alpha Gamer TS Booster Posts: 253   +46

  5. Darkshadoe

    Darkshadoe TS Guru Posts: 566   +105

    Linux command line: Powerful but painful. Just my opinion.
     
  6. Kibaruk

    Kibaruk TechSpot Paladin Posts: 1,337   +103

    I'm sorry... I might be a bit too old for this but it feels like welcome to dos 101 :p

    I still use the command line even in windows 8, it's a powerfull tool.
     
  7. Nice article. Here are a some other things that may be worth knowing:
    Linux is case sensitive, so /home/Name is different from /home/name
    ls -l show long listing format - displays permissions, owners, size, date
    ls -R recursively list files in subdirectories
    nano is a simple easy to use word processor, good for changing basic files
    vi is a powerful word processor, though a bit tricky to learn (need to remember various commands)
    mkdir dirname creates a directory called dirname
     
  8. mkdir norp
     
  9. Blkfx1

    Blkfx1 TS Addict Posts: 890   +171

    Good article. Some nice additions would be wildcarding and redirection. Linux command line is a big pain as it's hard to learn initially. It's super convenient once you get the hang of it though.
     
  10. The find command needs to have quotes, -name "*.c"
     
  11. It's great to have an article like this, but it needs a bit of work. Some examples,
    1. The home directory doesn't have to be the same name as the user name. That's just the default.
    2. The home directory is covered but it isn't mentioned that ~ refers to the home directory, and that's why the command prompt is as it is.
    3. ls doesn't do colour by default.
    4. Creating a new file with touch is pretty pointless. It implies you need to create a file before you can edit it. The purpose of touch is to update the modification/access time of a file.
    5. rmdir is the command to remove a directory. rm -r is a recursive delete that shouldn't be recommended unless necessary.
    6. The find example is broken, as above.
     
     
  12. yRaz

    yRaz TS Addict Posts: 958   +114

    It's about time you guys did something like this, great article!
     
  13. Nobina

    Nobina TS Booster Posts: 413   +92

    Helpfull article, altough I don't use Linux, I used to and I rarely had to use the command line. As I remember cd command is also used in Command Prompt in Windows and MS-DOS.
     
  14. There is a reason we don't use dos anymore.
     
  15. cliffordcooley

    cliffordcooley TechSpot Paladin Posts: 6,119   +1,523

    There is also a reason, why some of us still uses DOS(command-line tools) too.
     
  16. Miranda

    Miranda TS Rookie

    And that reason is that most users have no interest in learning how to get the most from a computer, only ever master an extremely small computing skill set, and are generally more concerned with ease of use than speed, flexibility or automation. It's absolutely true that general users don't need a command line, and are apt to be more effective with an ***** proof GUI than a tool that takes time to learn to use well. If you want to keep improving your ability to use a computer, however, then a GUI only takes you so far, and you need to learn to use and love a CLI.
     
    Syed Aljunied and cliffordcooley like this.
  17. The CLI was swapped in favor of the GUI. With a GUI though your limited to what is presented to you. With a CLI it's much more dynamic allowing for some powerful commands. Microsoft have even jumped on this with their addition of PowerShell. Obviously a CLI is not as user friendly so naturally guides like this exist. This guide is very well written.
     
    Syed Aljunied likes this.
  18. Glad to see autocomplete and searching have been included - makes navigation so much faster. Every computing enthusiast should get an understanding of the commands presented (as they're now applicable to all OSs, including Windows).

    You may be wondering 'why not use the mouse'? Because there will be times when you have to automate tasks, and CLI is the best way.
     
  19. yukka

    yukka TechSpot Paladin Posts: 727   +30

    Good starting article. I did note that you mention piping cat to less which is fine to use as a simple example of how to use the pipe command. However, you don't need to pipe cat to less, you can just read the file using the less command I.e.. less myfile.sh Then you can traverse the file using the cursors or you can use the spacebar to move forward a page at a time, or the B key to move back a page at a time.
     
  20. JC713

    JC713 TS Evangelist Posts: 7,029   +913

    Thanks for this guide! I just got a Raspberry Pi and this may help a ton!
     
  21. jobeard

    jobeard TS Ambassador Posts: 13,449   +324

    As a developer, you use the CLI frequently. Linux installs using things like RPM, but at the bottom of the GUI is config & make CLI processors. Linux also favors tar, gzip & gunzip
    You can learn a lot of the CLI with the documentation package man and/or info
    use man man for an overview
    the terse synopsis is also seen using man -h (-h is the ms equiv of /?)
    I'll also mention some directory navigation tricks of the shell (that thing that reads the CLI inputs you type)
    given a login and a prompt like
    #
    pwd gives the current working directory
    #/users/jeff​
    moving to the webserver
    #pushd /apache/apache2.2.22/​
    -- do some work and then need to see a file in the home directory
    #pushd ~
    #pwd
    #/users/jeff​
    cat some.log​
    -- go back to the webserver (without retyping the whole bloody thing again)
    #pushd
    -- get to access server config
    #cd config
    -- work on the server config
    #vi httpd.conf​
    --- show you where we are
    #dirs
    /apache/Apache2.2.22/conf /users/jeff
    --- and move back to my home in one fell swoop
    #popd
    #pwd
    #/users/jeff​

    SO; pushd & popd operate like a stack;
    pushd moves to the new dir and places it on top
    popd forgets the top entry on the stack and makes the next one the current dir
    pushd x; pushd y; creates y, x
    pushd without an argument toggles the top two dirs
     
  22. neversleepz

    neversleepz TS Rookie

    Curious to see in point 5, cat file.txt is piped to the less command. Although it is a neat touch point to gently explain piping and how piping a long output from *any* command to less makes its navigable, it is far easier to contemplate `less file.txt`. As written it gives the impression that the only way you can read a long text file is with both cat and less. Same goes for point 6, I can `vi newfile.txt` instead of `touch newfile.txt; vi newfile.txt`
    Like where you are going with that introducing concepts silently thing, just think people will go I can't open and page a file all in one command, this is crap!
     
  23. You do not have to use pipes regarding cat [filename] | less.
    Just use less [filemane] or more [filename]
     
  24. Cd ..
    rm -rf
    then file a resignation letter
     


Add New Comment

TechSpot Members
Login or sign up for free,
it takes about 30 seconds.
You may also...
Get complete access to the TechSpot community. Join thousands of technology enthusiasts that contribute and share knowledge in our forum. Get a private inbox, upload your own photo gallery and more.