Found 572 Articles for Linux

How to Find User Account Info and Login Details in Linux?

Pradeep Elance
Updated on 03-Jan-2020 06:54:25
For the sysadmins, it is routine to monitor user details like who are active and who are not, who logged in in last 2 days, which users belong to a given group etc etc. To help these requirements, Linux provides below list of commands which can be used to gather various types of information about the CommandIt gives the id details of users including the group id along with the secondary group IDs and names of a user choosen by the system. But you also ask for a specific user’sdeatils by giving the userid value in the command.ubuntu@ubuntu:~$ id ... Read More

How to Find Linux Server Geographic Location in Terminal?

Pradeep Elance
Updated on 03-Jan-2020 06:52:37
For purpose of security, cyber-crime investigation, government compliance or just for curiosity we might ned to track the geographical location of a Linux server in the internet or at least the location of the server which diverts the internet traffic to the server we are interested in. It involves getting the I.P address of the server and using some third party services offered in the web, to map that I.P address to get the location. In this article we will see the steps to achieve that.Step 1 − Install curl jqThe curl package will make the http requests to the ... Read More

How to Empty or Delete a Large File Content in Linux?

Pradeep Elance
Updated on 03-Jan-2020 06:47:23
Usually a continuously growing files, needs to be emptied from time to time to accept the latest data from the next operation. There are various mechanisms to empty the file. We will see them one by one below. The common approach is the overwrite the target file by using > sign which should come from a source which is empty./dev/nullThis is a common method where we output empty result and then redirect that result to the target file.# Original file size $ls-lt -rw-rw-r-- 1 ubuntu ubuntu 2925 Jan 1 08:39 ref_file.txt # Redirect the output from /dev/null $ cat /dev/null ... Read More

How to Download and Extract Tar Files with One Command in Linux

Pradeep Elance
Updated on 03-Jan-2020 06:43:54
We can download any required file form the web using the linux terminal. But many times it is found that the downloaded file is a zipped file which is in tar format. In this article we will see how to download and extract the file in a single command.Using wget and tarThe wget command downloads the data form the given URL while the tar command does the extraction of the tar.gz files.$ wget -c -O - | sudo tar -xzRunning the above code gives us the following result:--2020-01-01 07:25:18-- Resolving ( Connecting to (||:443... connected. ... Read More

How to download a website page on Linux terminal?

Pradeep Elance
Updated on 03-Jan-2020 06:40:41
The Linux command line provides greta features for web crawling in addition to its inherent capabilities to handle web servers and web browsing. In this article we will check for few tools which are wither available or can be installed and used in the Linux environment for offline web browsing. This is achieved by basically downloading the webpage or many webpages.WgetWget is probably the most famous one among all the downloading options. It allows downloading from http, https, as well as FTP servers. It can download the entire website and also allows proxy browsing.Below are the steps to get it ... Read More

How to do simple Arithmetic on Linux Terminal?

Pradeep Elance
Updated on 03-Jan-2020 06:41:18
While some GUI based Linux desktops give a calculator to be used in a similar way to what is available in Windows, the terminal has lot of features to do both simple and advanced level arithmetic calculations. In this article we will see how we can invoke various calculations from the Linux terminal itselfUsing bcThe command bc stands for basic calculator. Using it we can do various operations like arithmetic calculations, assigning values to variables, using comparison or relational operators and using many math functions available through bc itself. Also it has features for conditional statements and iterative statements. Below ... Read More

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

Pradeep Elance
Updated on 03-Jan-2020 06:37:46
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
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
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-Jan-2020 06:33:11
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