Linux
Linux
2. To print something:
echo [the string you want to print] > It will output any text
that we provide
whoami
ls (In ls command "-a" flag can be used to list all the contents
including hidden files and "-l" flag can be used for long listing)
ls [path to directory]
cd [directory name]
cd [path to directory]
• For example if there are two folders Desktop and Documents
under root directory and we want to move from this path
/root/Desktop to Documents so we can directly use command:
cd ../Documents OR cd ~/Documents
cat [filename]
pwd
eg: echo hello123 > test.txt (If test.txt file already exists it will
overwrite the file)
9. Creating a file:
touch [filename]
OR
Back slash is used so that CLI could interpret that this space is part
of the directory name. It is called Escape Sequence.
rm [filename]
rm -r [directory name]
file [filename]
nano [filename] (This will open a new window to edit the file)
File Permissions:
1. Files and Permissions:
• By doing long listing (ls -l) we can see the file or directory
permissions. The permission section has total 10 bits and it looks
like:
-rwxrw-r--
Here 'r' stands for read, 'w' stands for write and 'x' stands for
executable.
• The first bit shows that if it is a file or directory. If it is file '-' will be
placed and if its directory 'd' will be placed.
The last nine bits are divided in trio. The first trio is the permission
of the owner of file. The second trio is the permission of the group
that this file belongs to and the third trio is the permission of all
the other users.
2. Modify Permissions:
• Symbolic Format:
To add a permission:
To remove a permission:
In numeric form 4 stands for read, 2 for write and 1 for execute.
eg: chmod 754 myfile (This will give rwx permission to owner, rx
to group, r to users)
Common directories:
1. /etc:
2. /var:
The "/var" directory, with "var" being short for variable data, is
one of the main root folders found on a Linux install. This folder
stores data that is frequently accessed or written by services or
applications running on the system. For example, log files from
running services and applications are written here (/var/log), or
other data that is not necessarily associated with a specific user
(i.e., databases and the like).
3. /tmp:
4. /root:
Unlike the /home directory, the /root folder is actually the home
for the "root" system user. There isn't anything more to this folder
other than just understanding that this is the home directory for
the "root" user. But, it is worth a mention as the logical
presumption is that this user would have their data in a directory
such as "/home/root" by default.
Exercise:
You've been provided with a new Linux system. Perform the following tasks: