Show Menu
Cheatography

C++ FIRST TEST Cheat Sheet (DRAFT) by

test aid for class test

This is a draft cheat sheet. It is a work in progress and is not finished yet.

What is shell

When we speak of the command line, we are really referring to the shell. The shell is a program that takes keyboard commands and passes them to the operating system to carry out. Almost all Linux distri­butions supply a shell program from the GNU Project called bash. The name “bash” is an acronym for “Bourne Again Shell”, a reference to the fact bash is an enhanced replac­ement for sh, the original Unix shell program written by Steve Bourne.

Terminal Emulator

When using a graphical user interface (GUI), we need another program called a terminal emulator to interact with the shell. If we look through our desktop menus, we will probably find one. KDE uses konsole and GNOME uses gnome-­ter­minal, though it's likely called simply “terminal” on our menu. A number of other terminal emulators are available for Linux, but they all basically do the same thing; give us access to the shell. You will probably develop a preference for one or another terminal emulator based on the number of bells and whistles it has.
 

Making Your First Keystrokes

[me@li­nuxbox ~]$ This is called a shell prompt and it will appear whenever the shell is ready to accept input.
Note: If the last character of the prompt is a pound sign (“#”) rather than a dollar 2 sign, the terminal session has superuser privil­­eges. This means either we are logged in as the root user or we selected a terminal emulator that provides superuser (admin­­is­t­r­ative) privil­­eges.
[me@li­nuxbox ]$ kaekfj­aeifj Because this command makes no sense, the shell tells us so and give us another chance. bash: kaekfj­aeifj: command not found [me@li­nuxbox ]$
Command History If we press the up-arrow key, we will see that the previous command kaekfj­aeifj reappears after the prompt. This is called command history. Most Linux distri­butions remember the last 1000 commands by default. Press the down-arrow key and the previous command disapp­ears. Cursor Movement Recall the previous command by pressing the up-arrow key again. If we try the left and right-­arrow keys, we'll see how we can position the cursor anywhere on the command line. This makes editing commands easy.
date command [me@li­nuxbox ~]$ date Thu Mar 8 15:09:41 EST 2018
command is cal which, by default, displays a calendar of the current month. [me@li­nuxbox ~]$ cal March 2018 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
To see the current amount of free space on our disk drives, enter df. 4 Try Some Simple Commands [me@li­nuxbox ~]$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 15115452 5012392 9949716 34% / /dev/sda5 59631908 26545424 30008432 47% /home /dev/sda1 147764 17370 122765 13% /boot tmpfs 256856 0 256856 0% /dev/shm
Likewise, to display the amount of free memory, enter the free command. [me@li­nuxbox ~]$ free total used free shared buffers cached Mem: 513712 503976 9736 0 5312 122916 -/+ buffer­s/c­ache: 375748 137964 Swap: 1052248 104712 947536
Ending a Terminal Session We can end a terminal session by either closing the terminal emulator window, by entering the exit command at the shell prompt, or pressing Ctrl-d. [me@li­nuxbox ~]$ exit