Home Home > 2014 > 06 > 10 > Command Line Tuesdays – Part One
Sign up | Login

Command Line Tuesdays – Part One

June 10th, 2014 by

Here we are geekos, back in action! Sorry it’s been a while, but let me just assure you we’re back on track, raging to meet the deadlines and to, well, have some fun :)

Now, the whole idea was pretty much completely summed up in the introductory text posted a fortnight ago, so we may get down to business. As the book by Mr. Shotts instructs, we need to know what a shell is, as we’ll be operating withing it, and what a terminal emulator is.

A shell, Mr Shotts states, is actually what we’re talking about when we’re talking about command-line. The shell is basically a program that passes the strokes of your keyboard to your computer, a translator of some sort, so your computer knows what you’re saying. There are many shells in existence, but the most widespread shell used in GNU/Linux distributions is called bash, or Bourne Again Shell. It’s a clever wordplay, as Mr Bourne created the bash’s predecessor, sh, and Brian Fox wrote it as a free alternative for sh. Ahhh, GNU people and their humor, very clever :)

bOURNE

Next thing we need so we can interact with the shell is a terminal emulator. Every Linux distribution comes with one, depending on the desktop environment you use, so it should be Konsole from KDE, Gnome terminal in Gnome etc. Mr. Shotts says you probably develop a preference for one, but I use what the desktop environment provides me, most of the time.

Now, fire up your terminal. You get a line, stating your user name and the machine’s host name. This is called the shell prompt. It means it’s ready for you to enter a command. Let’s try something random. Type in anything, and press enter.

Hehe, remember the introductory saying we need to learn the commands as a poem? There we go, random doesn’t work.

Now, press the up arrow, and you’ll see the command reappear. What’s this sorcery? The up arrow key on your keyboard is for accessing the command history. The terminal saves up to 500 commands you entered, so to not type them over and over, you can look for them with the up/down arrow. The left and right arrows are for moving the cursor within a specific line, so you can edit the text in between. Now there’s another thing – ctrl+v for pasting text doesn’t work. You can set it up as a shortcut somewhere, but it’s usually something else. Check your terminal emulator’s shortcuts! (in Konsole, it’s Settings > Configure shortcuts)

Now, for us not to get the ‘command not found’ slap to the face, let’s try something simple. Type date. (Yes, I didn’t know there’s a command for this, so it’s exciting for me also) :) date

There you go. Why bother looking at your built in calendar in the clock, when you can fire up your terminal and type date, and see what day it is :) Just kidding, as Mr Shotts states, it’s a simple command, the more useful/difficult ones are coming next time. The related command to date is cal – it will display the current month’s calendar.

You may also try df, and it will list free space on your drives.

df

Or free, to display the amount of free memory:

free

If you’re already in the type-only mood, you can enter the command exit to get out of the terminal emulator instead of pressing the x button.

…and we’ll stop to a halt for this week so it won’t be too much to ingest on your already tight schedule. Too sum it up (you can write this conclusion down, for repetition), in part one, we learned:

  • what is a shell
  • what do we need to communicate with the shell (terminal emulator)
  • navigating the terminal commands with cursor buttons and exiting the terminal

Four simple commands:

  • date – displays the current date
  • cal – displays the current month’s calendar
  • df – shows the amount of free space on your hard drives
  • free – amount of free memory

What will we do next Tuesday?

We learn navigation through the file system (what are all those bin etc etc. folders, what are they used for, how to navigate through them via the terminal). Until then…

…have a lot of fun!dog

Both comments and pings are currently closed.

9 Responses to “Command Line Tuesdays – Part One”

  1. Note that nearly all terminal emulators allow pasting by right-clicking inside the terminal window and choosing “paste” (same with copy). So when in doubt, use contextual menus! :) Also of note is that you can select something and middle-click to paste it, although it’s not as intuitive to new people.

    Hah, I never actually knew about cal. Then again, I just use the calendar plasmoid :)

    Also of note is that df is right for simple filesystems (like ext4), but not very accurate with complex ones (like btrfs, in which case filesystem commands should be used instead, like `btrfs filesystem df /`). Oh, and both df and free show things in bytes, which is nice for computers but less so for people, so using `-h –si` (human readable, in SI units) makes that much easier to understand.

    • Sven

      @GreatEmerald What, use the mouse? You even have one? Heresy! Ctrl – Alt – F1 is the only way :-)

  2. Hi !!

    Great work, and useful I thik!!

    I’ll try to translate all this stuff into spanish for spread the word about this. Here you have this first article:
    http://victorhckinthefreeworld.wordpress.com/2014/06/11/la-consola-de-linux-para-novatos-i/

    ‘ve phun!! ;)

  3. sparkz_alot

    Great first lesson. Especially like the pictures :-)

  4. palp56

    Thank you!

  5. j.s

    appreciate it Nenad I will post it on opensuse.cz tomorrow :-)

  6. Nenad Latinović

    Thanks guys. Hope tomorrow will be as interesting :)

  7. Joe Root

    To strike up a conversation with
    /bin/csh,

    ask the system

    % gotta light?

  8. j.s

    C’mon Nenad people are asking about next chapter.