You are on page 1of 4

Technology Essentials: Linux Sum-up

By: Omar Mokhtar

Chapter 1: The Command Line Interface


We have learnt some of the “core” commands (commands that are essential to
any operating system) such as:
- ls: used for directory listing.
- cd: used to navigate directories within the file system.
- pwd: used to print the current directory we’re in.
- cp: used to copy files. (self-explanatory)
- mv: used to either rename files or to move the files. (self-explanatory)
- rmdir: used to remove directories.
- rm: used to remove files AND non-empty directories (more commonly used)
- etc..
Any command in Linux has the following syntax:
(COMMAND) (OPTIONS) (ARGUMENTS)
Options define HOW you want the command to be executed, Arguments are given
to the command to show WHAT the command should be executed on.
Do note that some commands do not require options or arguments, depends on
the usage of the command itself.
Lastly: The Linux/Unix OSes has this methodology: Everything is a file.

Chapter 2: Advanced Commands


There are some commands focusing on specific usages: such as “grep” which
filters out specific keywords either by string literals or by regular expressions.
“Tail” is used to view the last 10 lines of the file, intuitively we can use the -f
option to keep track of updates, this is important to keep track of log files.
“Ps” is used to view running processes/daemons running in the system and it is
used most with the “aux” option to view the processes running on the user who
has executed it.
“lsof” is used to view EVERY file that is used in the system, of course the output
would be huge so it has specific uses and options, one option we might use is the
-i option which views the files that have set an internet connection.
And there are all sorts of commands covered, we can always google them or use
the “man” or “apropos” commands to search for specific commands.

Chapter 3: Special Characters and Redirection


There are some “special” characters used within the terminal, some of which are
wild cards used for abbreviation and simplicity.
/ is the directory separator, one might say it’s the root directory, depends on the
context we’re using it in.
\ is the escape character separator, used for string literals.
* is the “all” wildcard, used to abbreviate all files.
? is the “single” wildcard, used to abbreviate one character.
Etc...
|| is used to multiple command execution, if the first fails, the second executes.
&& is the same as before but if the first executes, the second executes.
; is the same as before but its an independent separator meaning if the first fails
or executes, the second WILL execute when the first finishes.
For redirection
We must know that Linux has stdin, stdout and stderr:
each of which has a number 0,1,2 consecutively.
We can use the “<” and “>” to redirect inputs and outputs from/to files.
Do note that errors have a specific buffer for them called stderr so if the command
does not execute and an error occurs, it WILL not be put an output to the file.
Piping is used to redirect the output of commands as an input for the second
command, more like a cascade form: we use the “|” for that.
Example: cat file1.txt | grep “hi”
So what will happen is that file1.txt content will be printed to grep “hi” which will
then filter out that output and output to us (stdout) the filtered output of the first
command.

Chapter 4: Conclusion
Environment Variables are variables that hold important data for programs to use,
we can access that by using the “env” command.
Important variables: SHELL and PATH
Linux has a great way of dealing with multi users.
To create a user, we execute “useradd <username>”
To change the password of any user, we execute “passwd <username>”
There are some important files in Linux such as /etc/passwd which contains
hashed passwords and shell types for all users within the system.
/etc/shadow contains hashed passwords, either by MD5 or SHA512.
The “su” command is used to execute commands on behalf of other users in the
system.
The “Sudo” command is used for admin privileges.
Linux has a similar boot process as to windows with a few exceptions: it has the
GRUB bootloader and from there executes the init.d script which is the script with
PID 1 and every process from there is considered a child of that script.
The init.d script executes the targeted runlevel’s programs and scripts.
Linux has different runlevels suited for the environment, such as graphical.target
(for normal PC usage), rescue.target (used to troubleshooting) and multi-
user.target (used for servers that do not need a GUI)
We can use the systemctl and runlevel commands to manage these runlevels.
/etc/rcX.d contains the scripts associated with each runlevel, where X is the
number of the runlevel.
The Linux System has a versatile filesystem where everything is a file, below is a
picture of that file system:

Last but not least is how to install software in Linux which is done using the “apt”
command because apt is the default package manager in Debian.

You might also like