Super User & File Permissions
Linux Users
The root user, also known as the superuser or administrator, has access to all commands and files.
Root User
Linux Commands
Executable Path
Syntax :
Example :
Create New Users
Syntax :
Example :
Set/Change User Password
Syntax :
Example :
Execute Command as Another User
File Permissions
Authorization Levels
Multi-user operating systems like linux provide two levels of authorization in securing the files
Ownership
Permission
User Ownership
Users accessing a file/ directory can be categorized into 3 types
Type | Description |
---|---|
Owner | User who is considered as owner |
Group | A group of users, who are assigned a specific permission |
Others | Any other users who doesn’t belong to the above two types |
Ownership and Permissions
Permissions | Description |
---|---|
Read | Open and read a file |
Write | Modify the contents of a file |
Execute | Authority to run as a program |
File Permissions in Linux
Changing Permissions
Syntax :
Example :
"chmod" stands for change mode
Number | Binary | Symbol | Permission Type |
---|---|---|---|
0 | 000 | --- | No Permission |
1 | 001 | --x | Execute |
2 | 010 | -w- | Write |
3 | 011 | -wx | Execute + Write |
4 | 100 | r-- | Read |
5 | 101 | r-x | Read + Execute |
6 | 110 | rw- | Read +Write |
7 | 111 | rwx | Read + Write +Execute |
Changing Ownership
- For changing the user of a file/directory
Syntax :
Example :
- For changing the user and group of a file/directory
Syntax :
Example :
Packaging
Package & Repository
A package file is a compressed collection of files that comprise the software package
Packages are stored in repositories to make them accessible to users
Package Managers
apt
APT stands for the Advanced Packaging Tool
It is used to install, upgrade or remove software packages in linux
Syntax :
Installing Package
Installing a package from a repository
Syntax :
brew
It is a Package Manager for macOS.
- With brewcommand you can install the packages in macOS.
- With
Installing Package
Syntax :
yum
Installing Package
Syntax :
Downloading Files From Web
wget
To install
- apt
- brew :
- yum:
Syntax :
Example :
curl
To install
- apt:
- brew :
- yum :
Syntax :
Example :
Searching a Package
Syntax :
Example :
Updating Packages
System checks against the repositories.
If newer version available of the program it will update the information about the existing packages and their versions available.
Updating a package from a repository:
upgrade
update
Listing Installed Packages
Adding Repository
PPA (Personal Package Archive) is an application repository that can be used to upgrade and install packages from third parties.
Syntax :
Adding the Private PPA's security key
Your Linux device can use that signature to check the authenticity of the packages.
Syntax :
Removing a Package
Syntax :
Summary
Command | Description |
---|---|
sudo | Temporarily elevates the privileges |
which | Used to identify the location of a given executable path |
useradd | Used to create a new user with the given username |
passwd | Used to set or change password of a given user |
su | Used to execute command as another user |
chmod | Used to change the access permissions of file |
chown | Changing the user of a file/directory |
apt | Used to install, upgrade or remove software packages in linux |
wget | Used for downloading files from the web |
curl | Used for transferring data from or to a server |
apt-cache | Searches for a particular package |
add-apt-repository | Used to add repository |
apt-key | Used to add PPA security key |
Under the installation of an
Update command from
to
for a seamless monogodb installation.