Found 1437 Articles for Linux

How to disable delete permission of File and Directory in Linux?

Pradeep Elance
Updated on 03-Jan-2020 06:37:46

2K+ Views

Many times there can be un-intentional delete of files or directories. That can lead to loss of important data or some misconfiguration of the system so we need a way to stop the accidental deletion of files and directories it may not be applicable to all the files and directories but we can have a design where at least some files and directories are prevented from such scenario.We use the change attribute command to prevent scenario below will see how this command is applied to two files and directories.SyntaxBelow is the syntax of change attribute command.chattr [operator] [flag] [filename] Where ... Read More

How to Determine the File System Type in Linux (Ext2, Ext3 or Ext4)?

Pradeep Elance
Updated on 03-Jan-2020 06:36:36

23K+ Views

The file systems in Linux can be of different types. They support different file sizes and some mechanism like journaling etc. Also different types of file systems are supported by different Linux Kernel systems. So for the devices which are available as memory in the Linux System, we can determine their file types by using the following commands.Using lsblkThis command dispalys all the attached divices as well as their file types and partitions.$ lsblk -fRunning the above code gives us the following result −NAME FSTYPE LABEL UUID MOUNTPOINT sr0 sda ├─sda2 ├─sda5 swap 02a54ace-c5c2-41cf-a679-acd9b460ee79 [SWAP] └─sda1 ext4 ae7c051f-451b-45ad-80a3-347c70a9de5e /Using fileIt ... Read More

How to Create Multiple User Accounts in Linux?

Pradeep Elance
Updated on 03-Jan-2020 06:32:22

4K+ Views

Adding a single new user to a Linux system can be achieved through the useradd command. But system admins often get request to add many users. So Linux provides a different to do a bulk addition of many users to a system.This is the newusers command.Synatxsudo newusers user_deatils.txt user_details.txt is the file containing the details of all the usernames to be added.User DetailsBelow we see the structure of user_details.txt file.UserName:Password:UID:GID:comments:HomeDirectory:UserShell So we create a file with below details to add many usres.~$ cat MoreUsers.txt uname1:pwd#@1:2112:3421:storefront:/home/uname1:/bin/bash uname3:pwd#!@3:2112:3525:backend:/home/uname3:/bin/bash uname4:pwd#$$9:9002:4721:HR:/home/uname4:/bin/bashGiving Permissions to the User Details FileBefore we sue the user details file to ... Read More

How to Create a Shared Directory for All Users in Linux?

Pradeep Elance
Updated on 03-Nov-2023 03:46:34

32K+ Views

When multiple users need access to the same set of directories of files then we need to create shared folders to be used by the users. In Linux there is concept of users and groups which can be given certain level of permissions that will enable them to share the data. Below are the steps how to create the shared folders where users can and update the files individually.Step 1 − Create the folder to be sharedAssuming we are setting up the shared folder from scratch, lets create the folder. The -p will create the directory and would ignore any ... Read More

How to Count Word Occurrences in a Text File using Shell Script?

Pradeep Elance
Updated on 03-Jan-2020 06:29:40

8K+ Views

Linux shell scripting has many powerful tools to process the data in files. One such feature is to find patterns and count the number of occurrences of matched patterns. One such example is to count the number of occurrences of a specific word in a given file. This is achieved by combination of commands for pattern search and counting. Below are the approaches which can be used for this need.Input fileLets use the below file for demonstrating the examples.$ cat inspire.txt Mastering anything needs practice. It also needs patience. And it needs time and other resources.Using grep and wcThe grep ... Read More

How to Count Number of Files and Subdirectories inside a Given Linux Directory?

Pradeep Elance
Updated on 03-Jan-2020 06:27:19

3K+ Views

It often becomes essential to know not just the count of files in my current directory but also the count of files from all the subdirectories inside the current directory. This can be found out using theUsing lswe can use ls to list the files, then choose only the ones that start with ‘-‘ symbol. The R option along with the l option does a recursive search. The ‘-c’ option counts the number of lines which is the number of files.ls -lR . | egrep -c '^-'Running the above code gives us the following result −13Using find With Hidden FilesThe ... Read More

How to Copy File Permissions and Ownership to Another File in Linux?

Pradeep Elance
Updated on 27-Jul-2023 13:29:22

872 Views

Many times while taking back up of data from one location to another or configuring software, we need to maintain the same level of ownership and permission of the files. Creating those permissions and granting ownership to individual files can be error prone of done by typing commands for each of the files. So we use some arguments with the chown and chmod commands.OwnershipWe use the –-reference swiych in the chown function to specify the ownership cloning from the source file to the target file.Syntaxchown --reference=source_reference_file target_fileIn the below example we have a source file whose ownership gets cloned to ... Read More

How to Clear BASH Command Line History in Linux?

Pradeep Elance
Updated on 26-Jul-2023 15:55:07

519 Views

As we execute various commands they get stored in a file called .bash_history. We can refer to this file later to find all the commands. Sometimes there may be sensitive information in bash commands. To remove the sensitive information, we may remove specific lines from the bass history file or we may remove the entire file itself. In this article we will see both the approaches.Here we see the .bash_history file.$ ls -l .bash_history $ cat .bash_Running the above code gives us the following result −-rw------- 1 ubuntu ubuntu 6495 Dec 31 19:30 .bash_history Clearing Individual commandsTo clear a specific ... Read More

Create Shortcuts to Long and Complicated Paths in Linux (Gogo)

Pradeep Elance
Updated on 03-Jan-2020 06:20:28

87 Views

Gogo is a tool to bookmark directories with long and complicated paths in the Unix shell. Because the long parts are difficult to remember and cumbersome to type in. In this article we'll see how to install go go and use it.Installing gitWe first need to have git installed in our system which will be needed for gogo installation. To install git in an Ubuntu system follow the below command.$ sudo apt install gitRunning the above code gives us the following result −[sudo] password for ubuntu: Reading package lists... Done Building dependency tree Reading state information... Done The following additional ... Read More

Difference between Linux and Unix

Mahesh Parahar
Updated on 31-Oct-2023 03:53:47

18K+ Views

LinuxLinux is an open source multi-tasking, multi-user operating system. It was initially developed by Linus Torvalds in 1991. Linux OS is widely used in desktops, mobiles, mainframes etc.UnixUnix is multi-tasking, multi-user operating system but is not free to use and is not open source. It was developed in 1969 by Ken Thompson team at AT&T Bell Labs. It is widely used on servers, workstations etc. Following are the important differences between Linux and Unix.Following are the important difference between Linux and Unix.Sr. No.KeyLinuxUnix1DevelopmentLinux is open source and is developed by Linux community of developers.Unix was developed by AT&T Bell labs ... Read More

Advertisements