Introduction To Linux Commands
Introduction To Linux Commands
Commands
Nicolas El Khoury
Introduction
Linux Shell
Basic Linux Commands
Introduction
Linux is an Operating System, similar to Microsoft Windows and MAC OS. It is
completely open source and free. Several distributions (flavors) exist, including, but
not limited to Ubuntu, Kali Linux, Red Hat Enterprise Linux (RHEL), CentOS, etc.
Linux Servers are used across the vast majority of the servers online due to their
fast, secure, and free characteristics.
Linux Shell
One way to interact with the Operating System is through the Graphical User
Interface. However, this is not the only way. As a matter of fact, most Linux servers
online cannot be accessed through a GUI. An alternative is using the Command Line
Interface, which allows the user to interact with the Operating System through
commands. The Linux Shell is then a program that takes these commands from the
user and sends them to the Operating System to Process.
pwd - Short for Print Working Directory. As the name states, this command
prints the absolute path to the current directory.
ls - List files and directories. There are many flags that can be used with this
command. An example is ls -lah:
man - Displays the user manual for any Linux command (i.e., man ls displays
information about the ls command).
cp - Copy files and directories from the source to the destination. For example,
cp /home/ubuntu/directories/directory1/newFile.txt /home/ubuntu/directories copies
the newFile.txt file from its old directory to /home/ubuntu/directories .
mv - Move files and directories from the source to the destination. For example,
mv /home/ubuntu/directories/directory1/newFile.txt
1. Write to the console: echo 'hello world!' prints “hello world!” to the console.
2. Write to file: echo 'hello world!' > file.txt prints “hello world!” to a file
named file.txt
nano - Text Editor. nano file.txt . Allows us to access and edit a file. nano
to read-only chmod 400 nanoFile.txt . As you can see, the permissions clearly
changed giving the user only read permissions. Now attempting to modify the
content of the file won’t work.
sudo - Short for “SuperUser Do”. Performs a command with root permissions or
privileges. Similar to “Run as Administrator” on Windows. sudo chown root:root
nanoFile.txt . This command is now performed using root privileges. Since we
are logged in using the ubuntu user, we are no longer able to see the contents of
the file without using sudo .