Basic of Linux
Basic of Linux
1. Open source
2. Secure
3. Simplified updates for all installed software
4. Light weight
5. Multiuser – Multitask
6. Multiple distribution – Red Hat, Debian, Fedora, Ubuntu, KALI Linux.
1. cat =
1. Create file: To create a single file.
2. Concatenate file: To add more than one file into a single file.
3. Copy files: To copy the content of file x into file y.
4. To exit: Use ctrl+d.
5. If you want to add something in your existing file, you can add with the help of this
command. But you cannot edit anything in that file, you can only add.
6. tac: To see the content, from bottom to top.
2. Touch=
1. Create an empty file.
2. Create multiple empty files.
3. Change all timestamp of a file.
4. You can update access time or modify time individually too, of the file.
5. touch -a & touch -m (commands for above line).
3. vi/vim (editor):
2. It can be used to edit all kinds of plain text, it is especially useful for editing programs, mainly used
for Unix programs.
Commands –
:w – to save
Esc = Press esc to come back from the editing or adding zone.
4. Nano:
To create a file, and edit a file too.
Use ctrl+x = to exit, and Y = to save and press enter.
ls -l or ll = To see the list of directory and files, with details (ll includes hidden files).
ls -a = To see the list of all directories and files (included hidden one).
history = to see the history of the commands, which you have already run.
.filename/.directoryname = If you want to create a hidden file or hidden directory, just use . (dot)
before the file name.
cp = To copy a file data into another file. But the data of another file will be removed, once used this
command.
rm -r = To remove directory.
which = To check the location of installed Package (software) or whether it is installed in your system
or not.
tree = To check the details of the directory and files in one page. (apt-get install tree).
sudo apt install “package name” = To install a package (software) in our system.
Service (systemctl) nginx start = To start the nginx (if it is showing inactive).
Service nginx status = To check the status of your nginx. It is active (running) or not.
Cd /var/www/html = It is the location, where we can see and make index.html file.
Echo = If your machine has been using by others users too, then this command will help you to pass
the message to them. (To highlight the message).
Echo >filename
Grep = If you want to see the specific content in your file (like – name, contact no or whatever). It
works same like, ctrl+f works in windows.
useradd = To create the user. Like in windows we create user by the control panel, so that the user
cannot have the admin rights. Eg- useradd ajay
Note – when we create a user, then the group will automatically be created by the same name.
Eg- cat /etc/group – location to see the existing groups. We can also see the users which is already
added in that group.
Note – But when we create the group, the user will not be created by the same name.
gpasswd -a = to add the user into group. & use -M to add multiple users into the group. Use (,) to
separate the users.
cat /etc/group – to check, if the user has been added in the group or not.
Note – if you want to add any user in the group, then you must create the user first.
ln = To create a hard link (backup) of your file. And the hard link automatically syncs with your
original file. Even if you delete your original file, the data will not be affected here. As it works like a
backup file. Weather you update your original file or backed up (hard link) file. The data will be
updated in both files at the same time.
ln -s = To create a soft link of your file. It is also sync with your original file, but when you delete your
original file then you will not see the content of your file here, as it works like a shortcut.
Eg – tar -cvf filename.tar filename. tar -xvf filename.tar – to extract the tar file.
Eg – gzip filename
Access modes/Permissions
Read (r) (4) = Allows users to view (display) the content of a file or list the contents of a directory.
Write (w) (2) = Allows users to modify the content of a file or create/delete files within a directory.
Execute (x) (1) = Allows users to execute a file (if it's a script or executable) or enter into a directory.
Others = Any user who is not the owner and not part of the group.
Method 1:
= Each permission is assigned a numeric value: read (4), write (2), and execute (1).
For example, "rwx" becomes 7 (4 + 2 + 1), "rw-" becomes 6 (4 + 2), and "r--" becomes 4 (4).
(r = 4, w=2, x=1)
Commands:
Method: 2 = (=, +, –)
U = user/owner
G = Group
O = Others