Linux

How to Compress file in Linux

Compress file in Linux Tar command in Linux In Linux, Tar command is used to reduce the file size Tar related Options $ tar –help Options Description -c –create Create a new archive. -x –extract Extract files from an archive. -t –list List the contents of an archive. -f –file=ARCHIVE Use archive file or dir ARCHIVE. -v –verbose Verbosely list files processed. Compression Options with Tar Options Description -a –auto-compress Use archive suffix to determine the compression program. -j –bzip2 Filter the archive through bzip2. -J -xz –lzma Filter the archive through xz. -z –gzip Filter the archive through gzip. Compress Directory with option ‘-cf’ $ tar -cf <folder-name.tar> <folder-name> In below example, i compressed Drupa8-vagrant directory with Drupa8.tar name. Verbose output shows which files and directories are added to the archive, use the -v option Compress Directory with Option ‘-v’ $ tar -cvf <folder-name.tar> <folder-name> Ex:- Compress Directory with Option ‘-z’ For archiving a folder compressed ‘gzip’, you have to use the -z option $ tar -czf <folder-name.tar.gz> <folder-name> Compress Directory with Option ‘-j’ You can instead compress the archive with ‘bzip2’, by using the -j option $ tar -cjf <folder-name.tar.bz2> <folder-name> Ex:- Compress Directory with Option ‘-J’ $ tar -cJf <folder-name.tar.xz> <folder-name> Ex:- Extract directory from archive $ sudo tar -xf <folder-name.tar> List the Compressed data List the contents of an archive file without extracting it: $ sudo tar -tf <folder-name.tar.bz2>

How to Compress file in Linux Read More »

LS command in Linux

Ls Command in Linux In Linux ,ls command is used to list the file and directory’s information. To view all options of ls command $ ls –help Options Description ls -a list all files including hidden file starting with ‘.’ ls –color colored list [=always/never/auto] ls -i list file’s inode index number ls -l list with long format – show permissions ls -la list long format including hidden files ls -lh list long format with readable file size ls -ls list with long format with file size ls -r list in reverse order ls -S sort by file size ls -t sort by time & date

LS command in Linux Read More »

PS Command in Linux

PS command in Linux PS command in Linux In Linux, PS command let you about the active and running process. To Display current running process in terminal $ ps To Display All running processes $ ps -A To Display running processes of specific User $ ps -u <username> To Display running processes in BSD format $ ps -au To Display running process with User, Time and Command $ ps -aux To Display running processes of group $ ps -fG <group-name>

PS Command in Linux Read More »

System Information in Linux

Getting about CPU and RAM in Linux In Linux Distribution, if you went to display and went to know about hardware the information of your system then below commands will help you. To get CPU information in Linux $ cat /proc/cpuinfoor $ lscpu To get Memory (RAM) information in Linux $ cat /proc/meminfo To know more about Memory (RAM) info, use free command to view. $ free –help Options Commands Description –help free –help for more options -b free -b memory in bytes -m free -m memory in Megabyte -g free -g memory in Gigabyte -h free -h memory in human readable format -l free -l show detailed low and high memory statistics -t free -t show total for RAM + swap

System Information in Linux Read More »

Check Disk Storage in Linux

Disk Management in Linux Directory Storage in Linux As Linux user, we should know how to check the Storage in linux Operating System. If you want to check the current directory’s storage then simply run the below command $ du -sh * Ex:- As you can see, it will show how much storage used by directories. For more Option of du command run the below command $ du –help Check Disk Storage in Linux Now check the Partition Storage in Linux $ df -h

Check Disk Storage in Linux Read More »

Linux Distribution and Version check

Linux Distribution and Version check Linux Distribution Check Let’s check which Linux OS you are using, Open your Terminal and type the following command.. $ lsb_release -a I am using Ubuntu Linux and OS Release is 20.04 Linux Systemd-based distribution Check more details about Linux OS $ cat /etc/os-release Uname Command in Linux Uname is a short form of Unix name. Uname command used to view Linux OS’s Name, Kernel, OS Version and Hardware information. $ uname –help Above command will view all Options related to Uname command Options Commands Descriptions -a -a Prints all information, omitting -p and -i if the information is unknown. -s –kernel-name Print the kernel name. -n –nodename Print the network node hostname. -r –kernel-release Print the kernel release. -v –kernel-version Print the kernel version. -m –machine Print the machine hardware name. -p –processor Print the processor type, or “unknown”. -i –hardware-platform Print the hardware platform -o –operating-system Print the operating system. –help Display a help message, and exit. –version Display version information, and exit.

Linux Distribution and Version check Read More »

Linux basics part-2

Linux basics part – 2 Creating Users in Linux Let’s create a user, open your terminal in linux $ sudo adduser <username> Example:- Now login created user $ sudo su – <username> Example:- $ sudo su – pramod $ whoami What is Group in Linux? Group is a generally a collection of users. In Linux, we can create the user accounts for users and add them in a different groups according to their role and set a privileges on them. Instead of setting the privileges on users, create a group and set a privileges on that group and add users in that group. So, its save your time. In Linux, there are two types of Groups Primary – primary group is create when we create user and remember primary group’s username and group name is same. Secondary – Secondary group is like existing group. for example, we have System Admin group, if we add a new user then the System Admin groups privileges automatically applied on new user. Creating Groups in Linux Let’s create Groups in Linux $ sudo groupadd <group-name> In below example, i have created one group named redient-security Here, redient-security name of group x group password 1002 group id Adding Users in group $ sudo usermod -a -G <groupname> <username> Here -a is append means adding and G is for Secondary group For example Adding Users in Multiple groups In Linux, we can add one user in multiple groups. $ sudo usermod -a -G <group-name>,<group-name> <username> For example:- $ sudo usermod -a -G redient-security,sredient pramod Adding Multiple users in a group $ sudo usermod -a -G <groupname> <username> In below example, i have added redient and pramod users in redient-security group Removing User from group gpasswd is used to remove user from a group with -d option. $ sudo gpasswd -d <username> <groupname> For example:- $ sudo gpasswd -d pramod sredient Create New User and add in Existing group in one commands $ sudo useradd -g users -G redient-security,sredient kovid here, -g is primary group, users is primary group name, -G option is for secondary group, redient-security and sredient is secondary group name and kovid is new user name

Linux basics part-2 Read More »

Linux Basics

Linux Basics Commands “Shortcuts increase your working productivity and save your time”. To Open Terminal, press Ctrl + Alt + T To Close Terminal. press Ctrl + Shift + Q Close Single Terminal Tab, press Ctrl +Shift + W To Move Cursor Open your terminal and type something To move cursor to beginning of the line, press Ctrl + A To move cursor to end of the line, press Ctrl + E To move cursor Forward, press Ctrl + F To move cursor Backward, press Ctrl + B To locks the screen Ctrl + L Search previously used commands Ctrl + R Show last executed command Ctrl + P Text manipulation Shortcuts Commands Description Ctrl + U Cut the line from the terminal, If your are at end of the line Ctrl + K Cut the line from the terminal , If you are beginning of the line Ctrl + Y Paste the copied items Ctrl + W Delete the word before the cursor and copy to clipboard Alt + T change the position of the words before the cursor Alt + L To make a single letter or whole word in Lowercase, at after the cursor Alt + U To make a single letter or whole word in Uppercase, at after the cursor Alt + D To Delete a single word after the cursor Alt + . To Print the last words written in previous command Ctrl + L To clear the terminal File Management Commands Commands Description pwd To check full path of the current working directory cd To change the directory cd .. To change current working directory to parent directory ls -l To list the files and directories in current or present working directory ls -ld To list directories ls -a To list files including hidden files ls -lt To list files sorted by last modified date and time ls -lh To list file size in human readable format ls -lR To Show all sub-directories recursively tree To see the representation of the file system starting from the current directory File and Directory related commands To Create file, i am using nano editor to create a file $ sudo nano <file-name> To Copy a file $ cp -p <source-path> <destination-path> In below example, i have copied redient-security file to Desktop To Rename a file $ cp mv <file-name> <new-file-name> In the below example i have renamed redient-security file to sredient To Remove or delete file $ sudo rm <file-name> To Create Directory $ sudo mkdir <directory-name> To Copy Directory $ cp -R <source-path> <destination-path> To Remove or delete Directory $ sudo rm -R <dirctory-name> To Remove loaded directory with files $ sudo rm -rf <directory-name> File & Directory permissions Now, here we will create one file and change their permissions. $ sudo nano redient-security Type some line and save it by pressing Ctrl + x and Y Now check the file permissions $ ls -l redient-security File and directory contains three types permission, User, Group and Others Here, -rw is permission for user -r– is for group -r– is for others r = read, w = write, x = execute Assign and Remove permission on File and Directory Method is same to change permissions of file and directory Let’s change the permissions of User To give read, write and execute permission to user run the below command $ sudo chmod u=rwx <file-name> Example:- If you want to remove read and write permission from the user then run below command $ sudo chmod u-rw <file-name> Example:- If you want to give read only access to user then run the below command $ sudo chmod u+r <file-name> In below example, i have removed all permissions from user and assign read only permission here, ” + ” sign is used for assign permissions and ” – “sign is used for remove permissions In same way you can assign read, write and execution permissions to user and remove permissions from user. Assign and Remove permissions from User, Group and Others using Numeric Codes Codes Description 0 No permissions 1 Execute only permission 2 Write only permission 3 Execute and Write permission 4 Read only permission 5 Read and Execute permission 6 Read and Write permission 7 Read, Write and Execute permission Lets start assigning read only permission to user, group and others $ sudo chmod 444 <filename> Example:- Give read, write and execution to User $ sudo chmod 744 <filename> In Same way you can assign permission to User, Group and Others Let’s change the permissions of Group and Others To give read and write permission to group run the below command $ sudo chmod g+rw <filename> Example :- To remove read and write permission from group run the below command $ sudo chmod g-rw <filename> Example:- Commands Description chmod g=rwx <filename> assign read, write and execute permission to group chmod g+rwx <filename> assign read, write and execute permission to group chmod g-rwx <filename> remove read, write and execute permission from group chmod g+r <filename> assign read only permission to group chmod g+w <filename> assign write only permission to group chmod g+x <filename> assign execute only permission to group chmod g-r <filename> remove read permission from group chmod g-w <filename> remove write permission from group chmod g-x <filename> remove execution permission from group Assign and Remove permissions from Others Commands Description chmod o=rwx <filename> assign read, write and execute permission to others chmod o+rwx <filename> assign read, write and execute permission to others chmod o-rwx <filename> remove read, write and execute permission from others chmod o+r <filename> assign read only permission to others chmod o+w <filename> assign write only permission to others chmod o+x <filename> assign execute only permission to others chmod o-r <filename> remove read permission from others chmod o-w <filename> remove write permission from others chmod o-x <filename> remove execution permission from others

Linux Basics Read More »

wpChatIcon
    wpChatIcon