Understanding Linux File Permissions and Ownerships

Image
From one of our previous articles "How to manage Linux Users and Groups" we discussed on how Linux becomes a multi-user OS, what is a user and a group with their configurations. By design, even though Linux allows multiple users can use the same computer in the same time without affecting others, Linux doesn't allow you to access or modify files belonging to other users. If Linux allows you to do it, that would be a security risk. But somehow they have implemented a security measure to mitigate that security risk. With that we can make sure only desired users and groups can access the relevant files and directories.

If we take a small demonstration. Here, we will log in as a normal user and try to access a root directory.


It gave a permission denied error when accessing. Why ? That's because /root directory is owned by user root. Only a privileged user can access or modify that.

So, Linux introduces two kind of factors which tells who can access or modify a file as w…

How to get help from Linux ?


From this article, we will learn how to get help from Linux. If you are a beginner or an inexperienced person, you wouldn't have an idea about what are these commands, what will they do ? what is the right command i need for getting my work done ? Like that.

So, in Linux terminal you can have several ways to get it's help. It's very very useful. As a beginner using those tools is good to get a better start.  We will check them one by one.

1) Using man command

syntax : man <command>

These are man pages like a manual page for each an every command. Using man page is the best way to get help from Linux. Because man pages gives you a full detail page about the command and it is having all the options you can use. Sometimes man pages will give you examples also how to use them. I prefer using man pages is more relevant for a beginner to get to know about the commands.

eg - man ls

How to use man pages in linux to get help ?


In a case like if you don't know what the exact command, but you have an idea what to do. Then you can search the man pages for a keyword like below.

syntax : man -k <keyword>

eg :

You need to find the command to copy a file. Then you can use the keyword string as "copy". So you could use  man -k copy



There you can find what is the command useful for your task. If you want to do a file copy to a directory, you can use cp command.
So, man -k <keyword> searches the keyword in man pages database and displays that matches for your request.

If you want to do a deep search, you can use man -K <keyword>. What this command doing is it reads all the man pages, content and displays all the pages that include your keyword.

2) Using --help command

syntax : <command> --help

eg : ls --help



I used here ls --help | less in order to view the page from the beginning. Otherwise it will show the end of the page as it is a large file.

* If you use --help, you need to know the command exactly. But in  man command you can find with  a keyword. That will be a plus point for using man commands.

3) Using the Tab Completion

If you can't remember the full name of a command or a path, but assume you know first or first two letters of the command or the path. Then you can get suggestions by double tapping Tab in your keyboard.

eg -

i) for a path, Assume there is a directory named "Documents" in you home directory. But you can't remember the it's name. You can do like below.


It types only letter 'D' and press double tab. Then you can have list of suggestions. The output changes with your input letters. But If you gave "Doc", the search results will be shown as below.



It matches the files with your input characters.

ii) for a command, suppose you need to know your virtual machine's host name. You type only host and press double tab. It will show the suggestions.


You can find the hostname command.

4) Using info command

syntax : info <command>

info is also a tool we can get help from Linux.

eg : info ls




Comments

Popular posts from this blog

Different types of users in linux

Understanding Linux File Permissions and Ownerships

SUDO: What is it in Linux ?