My Linux learnings as a beginner
Linux as a service
Linux is not a new tool when it comes to technology world. Almost everyone especially those working in cloud services often use it to issue commands to the AWS API Services, or run script and achieve complex tasks which is difficult to do so via console. Linux is a widely used tool for a variety of services such as system administration, networking, user management among other services. So I started to pickup Linux and to study its basics, and its usage.
Linux today is used in a variety of services like networking, system administration and cloud services. With respect to cloud, we use AWS Command Line interface (AWS CLI) to provision services in the from the cli without using console. Having an hands on with Linux helps you to navigate through the AWS cli which can be useful in times of troubleshooting.
Some Basic commands which I learnt
- Creating files - to create files in Linux one can use the nano or the vim command. To view the contents of the file we use the cat command.
Text editor using nano
- Creating and removing folders – to create a folder we use mkdir command, and to remove an empty folder we use rmdir command.
Note: You cannot remove a directory which has contents in it, by the rmdir command. To remove a non empty directory use rm -r command. (It is called recursive deletion)
- Input Output redirection (I/O redirect) – When you want the output of a command to be redirected to another command, I/O redirections is the most useful command for this. For eg. We want to add a text called “hello” to our morning.txt file. The file contents are below:
Now to add the text “hello”, we use the command: echo "hello" >> morning.txt.
“>>” is the command used for redirection
- Echo command – This is used to just print the contents onto the system output.
- Changing permissions for file ownership – Sometimes you want might want to change the permissions for certain files. For eg- you may want to give a permission of reading and editing a file (read and write access) to only a few people, and give only the read permissions to other people. To do this we use the chmod command.
There are three permissions groups: Owner, Group and Others.
The first permission rwx is for owner, second permission rwx is for group which the file belongs to, and third permission rwx is for others.
‘r’ means read access, ‘w’ means write access, ‘x’ means access to execute.
The following table gives an idea of the various permissions level
|3||Execute and write permission||-wx|
|5||Read and execute permission||r-x|
|6||Read and write permission||rw-|
In our example for morning.txt, we see that, all the three have read, write and execute access for the file morning.txt. We want to change the permissions such that owner, groups and others have only read and execute access, for this if we refer the table we find the code as 555, the first 5 is for owner, second 5 is for group, third 5 is for everyone else.
We use the chmod command for this: chmod 555 morning.txt ,
We see that the write access has been revoked for all.
- Grep command – grep command is used to search for something in the file where we want to search. For eg if we want to search all the lines starting with “Good” in the file morning.txt, we can give the command grep Good morning.txt.
Foe learning Linux I referred to the course of LPI Linux Essentials in A cloud guru (link pasted below). Also at times I referred to the site of stack overflow to resolve any troubleshooting.
With the advent of cloud technology, Linux has become a necessary tool especially when provisioning cloud services using command line. Learning Linux has been a very thrilling experience for me as you could do small things in very efficient way as compared to doing it via desktop or console. I am looking forward to learning more in this area and enhance my learning so that I can help Classmethod in various projects.