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

By Himanshu Arora ยท 41 replies
Oct 26, 2017
Post New Reply
  1. Do you think of the command line as an antiquated leftover from the past, or an old fashioned way of interacting with a computer? Think again. In Linux, it is the most flexible and powerful way to perform tasks. In this article, we will explore the basics of the Linux command line, including directory navigation, file/directory operations, and more.

    misor likes this.
  2. Siavash

    Siavash TS Booster Posts: 65   +20

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

    EClyde TS Evangelist Posts: 1,307   +429

  4. Alpha Gamer

    Alpha Gamer TS Evangelist Posts: 354   +116

  5. Darkshadoe

    Darkshadoe TS Guru Posts: 571   +113

    Linux command line: Powerful but painful. Just my opinion.
    ypsylon and psycros like this.
  6. Kibaruk

    Kibaruk TechSpot Paladin Posts: 3,286   +902

    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. MrBlkfx1

    MrBlkfx1 TS Evangelist Posts: 863   +204

    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"
    jobeard likes this.
  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 Nigerian Prince Posts: 2,319   +1,405

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

    Nobina TS Evangelist Posts: 1,336   +843

    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 TS Guardian Fighter Posts: 9,726   +3,700

    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.
  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.
    Raoul Duke and Syed Aljunied like 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: 861   +67

    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 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. Jad Chaar

    Jad Chaar Elite Techno Geek Posts: 6,515   +974

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

    jobeard TS Ambassador Posts: 11,158   +986

    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
    moving to the webserver
    #pushd /apache/apache2.2.22/​
    -- do some work and then need to see a file in the home directory
    #pushd ~
    cat some.log​
    -- go back to the webserver (without retyping the whole bloody thing again)
    -- get to access server config
    #cd config
    -- work on the server config
    #vi httpd.conf​
    --- show you where we are
    /apache/Apache2.2.22/conf /users/jeff
    --- and move back to my home in one fell swoop

    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
  25. shaina

    shaina TS Rookie

    Very interesting

Similar Topics

Add your comment to this article

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...