Posts

Showing posts from February, 2019

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…

SUDO: What is it in Linux ?

Image
Here, we are discussing about a very important topic in Linux. In a previous article about different types of users, we mentioned the name super users. In this article we are going in deep with super users topic in Linux. You will be learned each an every corner should be known.

Who is a super user in Linux ?

A privileged user who can gain root access for system administration.  Simply any user can be a superuser. But to gain that, root user should grant that user with superuser privileges. After becoming a superuser, it can switch to root immediately or can gain root power temporally for administrating the systems. All the commands needed for everything will be discussed below.

Where do you need superuser access ?

Administrating packagesUser administrationAccessing root owned filesOperating system level administration Above mentioned are a few places where you need superuser access. When a normal user tries to do above, they will get "Permission denied" message. Why does this…

Getting touch with Linux commands (part 4)

Image
Here, we will cover how to move and rename files. Just like "cp" command for copying files as discussed in previous article "Linux commands part 3", we can use "mv" linux inbuilt command for moving files in Linux operating system. In this article we will discuss most of the useful syntax's with mv command.

mv : Move command in Linux operating system. 

syntax : mv <options>  <source> <destination>

* source could be one or more sources and destination can be another different filename when renaming. 

eg_1 : How to rename a file

Here, we have created some files with subject names.



But, we need to rename the file named "language" with "english".  To rename we can use mv command as below.



eg_2 : How to move a single / multiple files 

Here, we have created a directory named "marks".



And we need to move the files ( english, history, maths, science ) to the new directory named "marks". We use mv command …

Getting touch with Linux commands (part 3)

Image
From the previous articles Linux commands part 1 and part 2 we covered the basic administrating commands needed for creation/deletion of directories/files, view files. Today we will discuss how to copy files and directories in a Linux operating system with it's syntax.

cp : copy command in Linux

We can use "cp" command to copy a single or multiple files and directories as well. Simply what does this command do ? "cp" command copy something from source location and pastes on the destination.

syntax : cp <options> <filename1> <filename2>

* here filename2 can be a directory path also. 

eg_1 : How to copy a single file

Here, we are in foo3 directory and we have a file named example_1. Below image shows it's content by using 'cat example_1' command.


Now we copy example_1 file and pastes it with another name as example_2. What it has done ? It has copy content of first file and pastes that content with another file with a different name.


S…

Wildcards - Linux

Image
What is a wildcard ? It's like a pattern of characters. You guess a pattern of characters and can be used wildcards to represent that. Simply we use wildcards to represent a set of characters with a pattern. It can be used with any commands. You can grab more referring below examples.

There is a basic set of wildcards,

* : This represents zero or more characters ( note that it's any character )? : This represents a single any character [ ] : This represents a range of characters matches for any occurrence enclosed within bracket. { } : More Similar as above.  Now we will take one by one with examples.

1) * : This represents any number of any character. 

eg_1 : * can be helpful in listing files inside of a directory.


There are some files named foo1,foo2,foo3,foo4 in my home directory. If we need to list files inside of all those directories, can be used the * wildcard as foo*. It checks the matches that starts with foo and the rest of the name can be anything. So foo1,foo2,foo3,…

Getting touch with Linux commands (part 2)

Image
From a previous article "Getting touch with Linux commands (part 1)", we could learn about some basic commands for listing files, showing the current directory, changing directories, viewing the contents of files such things. From this article we will go abroad of that.

When you are working in a Linux operating system, you must know the way of creating a new directory, how to copy files to that directory or remove files in that directory and how to move a file from one place to another place.

Here, we will learn how to work with directories in details.

1) mkdir : Create a new directory ( similarly a new folder in windows )

syntax : mkdir <directory name >

What is mkdir ? In linux, it allows users to create a single or multiple directories with mkdir command.

eg : mkdir myFiles


If you want to check with more details, you can go with ls -ld myFiles as shown below.



What is the difference in between ls -ld myFiles and ls -l myFiles. It will be shown below.



There you can see…