Which Linux characters do beginners use most? | Linux Tutorial
for Beginners (4:31)
Code Examples and Video Script
Welcome. Today's question: Which Linux characters do beginners use most?
I'm Paul, and believe me, I know that interpreting symbols in Linux is
a challenge for those coming from Mac and Windows.
Tackling them all is unrealistic and our goal really is to navigate
Linux enough to install a software stack for Data Science.
Step 1 - Context Defines What Symbols Do
So in this tutorial, I'll cover must-know characters and keystrokes
and prepare you to look the others up.
In any language, words have meaning depending on context, right? Well,
characters in Linux, and the bash
shell in particular, are the same. And because there are too many to
memorize, I'll point you to two sources for help, an online
Bash Manual, and a Cheat Sheet summarizing non-alphanumeric characters.
Then we'll practice with these nine essentials.
- / ~ ; # . > | Ctrl-c
(And practice with a few other commands).
sleep
bash
help
whatis
clear
ls
wc
less
exit
In the next video, we'll cover the basics of configuration files.
Step 2 - GNU Bash Manual
I'll hop over to a local Linux test server running Debian, and
summarize what we'll cover here using
whatis. Then I'll change directories
to /notes, list files, and we'll open
one in a minute.
paul@fullstack:~$ whatis sleep whatis less pwd ls wc exit
sleep (1) - delay for a specified amount of time
whatis (1) - display one-line manual page descriptions
less (1) - opposite of more
pwd (1) - print name of current/working directory
ls (1) - list directory contents
wc (1) - print newline, word, and byte counts for each file
exit: nothing appropriate
paul@fullstack:~$ pwd
/home/paul
paul@fullstack:~$ cd notes
paul@fullstack:~/notes$ ls
video0002.txt video0004.txt video0006.txt video0008.txt video0011.txt video0016.txt
video0003.txt video0005.txt video0007.txt video0009.txt video0012.txt video0017.txt
paul@fullstack:~/notes$ clear
Try an exercise, look at your keyboard and count the number of
non-alphanumeric keys. So no letters, numbers or function keys.
The letter c, for example, can only mean the letter
c; however, characters have many meanings, depending
on context.
On my keyboard there are 32, and I went left to right and created a
table shown here in less.
paul@fullstack:~/notes$ less video0016.txt
Linux non-alphanumeric characters (video 16)
## char name(s) context ## char name(s) context
-- ---- ------------------- ----------- -- ---- ------------------ -----------
1 ` backtick 17 | pipe, vertical bar redirection
2 ~ tilde directory 18 \ backslash
3 ! exclamation, bang 19 / forward slash directory
4 @ ampersand, at 20 { open curly brace
5 # number, pound, hash comment 21 } close curly brace
6 $ dollar symbol 22 [ open bracket
7 % percent 23 ] close bracket
8 ^ caret 24 " double quote
9 & ampersand 25 ' single quote, apos.
10 * asterisk, star 26 : colon
11 ( open parenthesis 27 ; semicolon commands
12 ) close parenthesis 28 ? question mark
13 _ underscore 29 < less than
14 - dash, minus, hyphen options 30 > greater than redirection
15 + plus 31 . period, dot directory
16 = equal 32 , comma
video0016.txt (END)
I put common names here and the context for those I'll discuss here.
So the tilde symbol ~ comes up when
we're talking about directories, pound
# for comments, and for dash
- it's options.
Why is it that characters have multiple meanings? First, it saves
keystrokes and second, it simplifies complex instructions.
Step 2 - Find Help on Characters
You know how to access the man bash
page, all 5,000 lines of it.
paul@fullstack:~/notes$ man bash
BASH(1) General Commands Manual BASH(1)
NAME
bash - GNU Bourne-Again SHell
SYNOPSIS
bash [options] [command_string | file]
COPYRIGHT
Bash is Copyright (C) 1989-2013 by the Free Software Foundation, Inc.
DESCRIPTION
Bash is an sh-compatible command language interpreter that executes commands read
from the standard input or from a file. Bash also incorporates useful features from
the Korn and C shells (ksh and csh).
Bash is intended to be a conformant implementation of the Shell and Utilities por
tion of the IEEE POSIX specification (IEEE Standard 1003.1). Bash can be configured
to be POSIX-conformant by default.
OPTIONS
All of the single-character shell options documented in the description of the set
builtin command can be used as options when the shell is invoked. In addition, bash
interprets the following options when it is invoked:
-c If the -c option is present, then commands are read from the first non-
option argument command_string. If there are arguments after the com
mand_string, they are assigned to the positional parameters, starting with
For those really hungry for bash
knowledge, I suggest the free 175-page
GNU Bash Manual, offered in a variety of formats.
Step 3 - Linux Cheat Sheet
I've summarized some of it in a
Linux Cheat Sheet you can
check out later. I'll keep improving it, so check in periodically.
Step 4 - Practice with Non-Alphanumeric Characters
The dash character in Linux
On the most used symbols for beginners. First, let's discuss dash
- and view the
man page for
whatis.
paul@fullstack:~/notes$ man whatis
paul@fullstack:~/notes$ man whatis
WHATIS(1) Manual pager utils WHATIS(1)
NAME
whatis - display one-line manual page descriptions
SYNOPSIS
whatis [-dlv?V] [-r|-w] [-s list] [-m system[,...]] [-M path] [-L locale] [-C file]
name ...
DESCRIPTION
Each manual page has a short description available within it. whatis searches the
manual page names and displays the manual page descriptions of any name matched.
name may contain wildcards (-w) or be a regular expression (-r). Using these
options, it may be necessary to quote the name or escape (\) the special characters
to stop the shell from interpreting them.
index databases are used during the search, and are updated by the mandb program.
Depending on your installation, this may be run by a periodic cron job, or may need
to be run manually after new manual pages have been installed. To produce an old
style text whatis database from the relative index database, issue the command:
whatis -M manpath -w '*' | sort > manpath/whatis
where manpath is a manual page hierarchy such as /usr/man.
OPTIONS
-d, --debug
(102 lines trimmed)
AUTHOR
Wilf.
Fabrizio Polacco.
Colin Watson.
2.7.0.2 2014-09-28 WHATIS(1)
But I could have used -h for help or
-V for version.
paul@fullstack:~/notes$ whatis -h
Usage: whatis [OPTION...] KEYWORD...
-d, --debug emit debugging messages
-v, --verbose print verbose warning messages
-r, --regex interpret each keyword as a regex
-w, --wildcard the keyword(s) contain wildcards
-l, --long do not trim output to terminal width
-C, --config-file=FILE use this user configuration file
-L, --locale=LOCALE define the locale for this search
-m, --systems=SYSTEM use manual pages from other systems
-M, --manpath=PATH set search path for manual pages to PATH
-s, --sections=LIST, --section=LIST
search only these sections (colon-separated)
-?, --help give this help list
--usage give a short usage message
-V, --version print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
paul@fullstack:~/notes$ whatis -V
whatis 2.7.0.2
paul@fullstack:~/notes$ clear
Of course, dash is used in other contexts as well.
The slash character in Linux
Second, slash /, so this is very basic,
but slashes denote folders. The first one being the root, or the base
of the directory structure.
Next, the tilde, ~, here (pointing to
output above) refers to my home directory. So this (pointing to
/home/paul/notes and this
~/notes are the same place).
You can always do this to go home.
paul@fullstack:~/notes$ cd ~
paul@fullstack:~$
The semicolon character in Linux
Next, the semicolon ; character is
for entering multiple commands at once.
paul@fullstack:~$ cd notes; pwd; ls
/home/paul/notes
video0002.txt video0004.txt video0006.txt video0008.txt video0011.txt video0016.txt
video0003.txt video0005.txt video0007.txt video0009.txt video0012.txt video0017.txt
paul@fullstack:~/notes$
The pound character in Linux
The pound # is a comment, meaning the
rest of the line is ignored.
The dot . occurs in many contexts,
but the most basic is that dot refers to the present directory. Using
an ls -a shows dots here, one dot is
the current directory and two dots points to one above.
paul@fullstack:~/notes$ ls -a
. video0002.txt video0004.txt video0006.txt video0008.txt video0011.txt video0016.txt
.. video0003.txt video0005.txt video0007.txt video0009.txt video0012.txt video0017.txt
paul@fullstack:~/notes$ ls .; ls ..
video0002.txt video0004.txt video0006.txt video0008.txt video0011.txt video0016.txt
video0003.txt video0005.txt video0007.txt video0009.txt video0012.txt video0017.txt
notes
(So listing files with one dot printed the first two lines and with two
dots it printed the third).
The greater than character in Linux
The greater than symbol > is used
to create a file on the fly.
For example, I could do an
ls on this directory and put it one
directory above, calling it lstest.txt.
paul@fullstack:~/notes$ ls . > ../lstest.txt
paul@fullstack:~/notes$ less ~/lstest.txt
(So listing files with one dot printed the first two lines and with two
dots it printed the third).
The pipe character in Linux
A similar symbol is pipe |, where
output from one command is handed off to another.
Here we use wc to count files.
paul@fullstack:~/notes$ ls | wc -l
12
The Ctrl+c keystroke combination in Linux
And last is the keystroke combination
Ctrl+c. If you ever get to the point
where you're lost and don't see a command prompt, it means a program
is running.
I've used one called sleep to mimic
what you might see.
We're just scratching the surface on characters here, and trying to
learn enough Linux to get our software stack installed so we can
start playing around with Math and Statistics in Python.
Client : HTML, CSS, JavaScript
Software : Python Scientific Stack
Data : PostgreSQL, MySQL
OS : Linux (command line), Debian
In our next video we'll talk about configuration files.
Have a nice day.
What's Next?
We have hundreds of free videos on YouTube. Subscribe and check it out.