Information about Linux and its Basic commands.
Linux is an open-source and free-to-use operating system. It was created by Linus Torvalds in 1991 and has since become a widely used and influential platform for developers and end-users.
Features of Linux:-
Open source -Linux is distributed under open-source licenses, meaning its source code is freely available for anyone to view, modify, and distribute.
2. Command Line Interface (CLI): Linux is known for its powerful command-line interface, which allows users to interact with the system using text commands. The terminal or shell provides a way to execute commands, manage files, and perform various tasks efficiently.
3. Multi-User and Multi-Tasking: Linux is designed to be a multi-user and multi-tasking system. Multiple users can log in and use the system simultaneously, and the operating system efficiently manages running processes.
4. Security: Linux is known for its robust security features. User permissions and access control mechanisms are used to protect system resources and data.
5. Server and Enterprise Use: Linux is widely used in server environments, running a significant portion of the internet’s servers.
6. Community Support: The Linux community is known for its active support and documentation
Windows vs Linux
Linux is versatile and can be used on a wide range of devices, from servers and desktop computers to embedded systems and mobile devices. Learning Linux can be valuable for system administrators, developers, and anyone interested in open-source technology.
Basic Commands in Linux
Linux provides a wide range of commands to interact with the system and perform various tasks. The Commands in Linux are passed through the terminal provided by the operating system.
Here are some of the Basic Commands:-
pwd (Print Working Directory): Displays the current working directory.
2. ls (List): Lists the files and directories in the current directory.
ls: It will display all files in alphabetical order (a to z)
ls -r: It will display all files in reverse alphabetical order (z to a)
ls -l: It will display a long listing of files
ls -t: It will display all files based on the last modified date and time. The most recent file will be displayed at the top and old files will display at the bottom.
ls -rt: It will display all files based on the reverse of the last modified date and time. Old files will display at the top and recent files will display bottom.
ls -a: It will display all files including hidden files (hidden files will start with .)
3. cd (Change Directory): Changes the current directory.
4. mkdir (Make Directory): Creates a new directory.
5. touch: Creates an empty file or updates the timestamp of an existing file.
Eg:-
6. rm (Remove): Deletes files or directories.
7. cp (Copy): Copies files or directories from one location to another.
8. mv (Move/Rename): Moves or renames files or directories.
9. cat (Concatenate): Displays the contents of a text file.
10. head/tail: Display the beginning or end of a file.
11. man (Manual): Displays the manual pages for a command.
Eg:-
‘man ls’ will display additional information for the ‘ls’ command
12. grep (Global Regular Expression Print): Searches for text within files using regular expressions
File permissions in Linux (Read,Write,Execute)
File permissions in Linux are of three types — read, write, and execute. These 3 permissions are made available to users, groups, and others.
File permission and their types in short
User: the owner of the file (person who created the file).
Group: The group can contain multiple users.
Therefore, all users in that group will have the same permissions. It makes things easier than assigning permission for every user you want.
Other: any person has access to that file, that person has neither created the file nor is he or they in any group that has access to that file.
Execute ls -ltra command to file permissions
$ ls -ltra
We will work with this part -rw-r--r--.
The characters mean:
r — — = read. — w — = write. — — x = execute. — — — = no permission.
$ -rw-r--r--
It represents file rw-: User r — — : Group r — — : Other
As we see above, the empty first part means that it is a file. If it were a directory then it would be the letter d instead.
The second part means that the user rw- has read and write permissions but he does not have the execute one.
The group and others have only the read permission.
To change the permission for any user/group/other, the following command is used:-
chmod (Change Mode): Changes file permissions.
$ chmod o+w f1.txt
This command will add the write permission for other users to my text file. Now if you try to execute ls -l then you will see — rw — r — — rw —.
$ chmod u+x f1.txt
The permissions will be — rwxr — — rw —
Removing the execute permission from the user: -
$ chmod u-x f1.txt
Above where a few basic commands to get started in learning Linux and these commands are very useful for interacting with the command-line interface of Linux.
In conclusion, Linux is easy and free to use. Learning Linux will help us to get better functionality and due to open source, many users can contribute to the development of Linux OS.