Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

Monday, March 30, 2020

Unix Ascendancy To Discovery Symbolic Link Or Soft Link Inwards Linux

There are 2 ways y'all tin detect a symbolic link or soft link inwards UNIX based operating organization e.g. Linux, Solaris, BSD or IBM AIX. The commencement way is yesteryear using ls ascendance inwards UNIX which displays files, directories, as well as links inwards whatever directory as well as other way is yesteryear using UNIX detect ascendance which has the mightiness to search whatever sort of files e.g. file, directory or link. In this UNIX ascendance tutorial, nosotros volition encounter examples both of these UNIX commands for finding a soft link inwards whatever directory. If y'all are novel to UNIX operating organization as well as non familiar alongside the concept of the soft link as well as difficult link, I would recommend getting a practiced manus on it, every bit it is i of the virtually powerful features of UNIX based system.


One to a greater extent than concept which is quite of import to larn is file as well as directory permissions because UNIX provides a unlike score of permissions as well as link inherit permission of finish folder where they are pointing out.

This is too a really popular Linux interview question asked on both organization admin every bit good every bit developer score interview. Anyways Let's start alongside the commencement instance of How to detect a symbolic link inwards UNIX using “ls” command:




ls ascendance to detect a symbolic link inwards UNIX systems

permission details of each file as well as directories, if y'all await carefully for links that String starts alongside modest  L ( 50 for the link).

If y'all combine the output of ls ascendance alongside grep as well as purpose a regular expression to detect all entries which start alongside modest L  than y'all tin easily detect all soft link on whatever directories.

Here is the sum UNIX ascendance instance of finding the symbolic link using ls as well as grep command:

java67@blogspot: ls -lrt
total 3.0K
-rw-r--r--  1 java67 Domain Users 79 Jul 19  2011 test.txt
drwxr-xr-x+ 1 java67 Domain Users  0 Jun fifteen 12:07 unix/
drwxr-xr-x+ 1 java67 Domain Users  0 Sep xix 12:30 java/
lrwxrwxrwx  1 java67 Domain Users  4 Sep xix 12:31 version_1.0 -> java/
lrwxrwxrwx  1 java67 Domain Users  4 Sep 21 13:59 os -> unix/


java67@blogspot: ls -lrt | grep ^l
lrwxrwxrwx  1 java67 Domain Users  4 Sep xix 12:31 version_1.0 -> java/
lrwxrwxrwx  1 java67 Domain Users  4 Sep 21 13:59 os -> unix/


The ^ grapheme is a exceptional regular facial expression which agency the start of the line. You tin farther check find ascendance inwards UNIX. Since all UNIX based operating organization e.g. Linux, Solaris or IBM AIX back upwards find, it's non solely available only virtually powerful way to detect a soft link inwards whatever directory or subdirectory.

When y'all purpose detect ascendance alongside option type as well as specify the type every bit modest L ( 50 for the link), it displays all soft link inwards the specified path.

For example, next the instance of detect ascendance volition demo all soft link inwards the electrical flow directory as well as its subdirectory :


java67@blogspot: find . -type l
./java/version_1.0
./os
./version_1.0

Here the dot (.) character denotes a electrical flow directory. 

Linux System Administration Fundamentals

Thanks for reading this UNIX tutorial, if y'all similar this instance as well as my explanation thus delight part alongside your friends as well as colleagues. If y'all bring whatever questions or feedback thus delight drib a note.

How To Discovery Swap Infinite As Well As Utilization Inward Solaris - Unix Command

Swap infinite inwards Solaris or whatsoever UNIX host is an of import disk infinite which is used for swapping procedure from physical retentiveness (RAM)  to disk. Virtual retentiveness allowed a procedure to run fifty-fifty if physical retentiveness gets amount past times using swap space (which is located on your difficult disk) to swap out memory pages which are non currently inwards use. In this UNIX ascendence tutorial, nosotros volition come across closed to Solaris commands to find configured in addition to electrical flow usage of swap space. Remember if your machine runs out of swap infinite in addition to then you lot tin non offset a novel procedure in addition to besides an erstwhile procedure which volition endeavor to expand themselves volition probable to fail. 


Another interesting indicate virtually swap infinite is that every procedure reserved swap space, equivalent to its physical retentiveness requirement thence that it tin swap out completely when required. Which way electrical flow usage of swap infinite denotes amount retentiveness used past times all procedure at that time. 

This UNIX ascendence tutorial is adjacent inwards our serial of articles e.g. UNIX ascendence to respect links , grep ascendence examples inwards UNIX and  10 most pop Linux Interview questions.



Solaris ascendence to respect Swap memory

host runs out of swap you lot tin non offset a novel process, thence hold upwards careful amongst how much swap infinite you lot educate in addition to your procedure doesn’t consume all swap retentiveness available inwards Solaris host.



Here is the output of swap ascendence amongst both swap -l in addition to swap -s alternative to come across how much swap infinite is left inwards the machine:

test $ swap -l
swapfile             dev  swaplo blocks   free
/dev/sd/dsk/swap 181,2       8 134217720 134217720

test $ swap -s
total: 22189856k bytes allocated + 8594616k reserved = 30784472k used, 80563112k available


That’s all on how to respect swap infinite usage inwards Solaris or How much swap infinite is used currently, how much swap infinite is available straightaway etc. There are a brace of to a greater extent than Solaris commands which displays information virtually swap infinite e.g. vminfo and sar.  

You tin farther check The Linux Command Line: Influenza A virus subtype H5N1 Complete Introduction to learning to a greater extent than virtually useful commands similar viminfo and sar


 or whatsoever UNIX host is an of import disk infinite which is used for swapping procedure from physi How to respect swap infinite in addition to usage inwards Solaris - UNIX command


You tin besides await on the mesh on How to role them to respect swap infinite in addition to and then cross banking enterprise jibe amongst the output of swap command. By the way, I e'er prefer swap ascendence to respect swap usage inwards Solaris operating system.


Other UNIX in addition to Linux Command Tutorials for Beginners
Linux Command Line Basics
Top 10 Networking Commands inwards UNIX-based Systems

Sunday, March 29, 2020

Unix Dominance To Discovery Ip Address From Hostname - Linux Example

IP address from hostname inwards UNIX
In this Unix ascendency tutorial, nosotros volition encounter How to discovery IP address of whatever host inwards a UNIX based system e.g. Linux, Solaris or IBM AIX. In full general hostname as well as IP address are 2 of import things nearly whatever host inwards a UNIX based network.  You ever demand either hostname or IP address to connect to whatever host. Some fourth dimension you lot desire to discovery IP address of localhost, exactly about fourth dimension IP address of exactly about other host on network etc. We convey shown exactly about techniques to find IP address from hostname inwards UNIX as well as hither nosotros volition encounter is especial listing of UNIX commands to larn IP address of localhost or host on which you lot are working along amongst whatever other host for which nosotros know hostname. 


List of UNIX ascendency to discovery IP address from hostname

Here is listing of UNIX command which tin dismiss last used to discovery IP address :

ifconfig
nslookup
hostname

ifconfig ascendency example
Let's encounter event of ifconfig ascendency to find IP address of localhost on which you lot are working :
ifconfig ascendency shows lot of information nearly diverse NIC cards inwards system, you lot tin dismiss cheque either for "inet" or "inet addr" for seeing IP address to respective NIC cards :



# /usr/sbin/ifconfig -a
inet 192.52.32.15 netmask ffffff00 broadcast 192.52.32.255

As I said ifconfig ascendency shows lot of details but I convey solely included relevant inet one, if you lot convey to a greater extent than than ane network carte du jour attached to that host, you lot may encounter to a greater extent than than ane inet address corresponding to each of them. Main drawback of ifconfig ascendency inwards UNIX is that you lot tin dismiss solely larn IP address of localhost from this command, you lot tin dismiss non larn IP address of whatever other host.

grep as well as hostname example
You tin dismiss combine grep command as well as hostname to expect IP address from /etc/hosts file. hither `hostname` volition render output of hostname ascendency as well as non bad volition hence search for that give-and-take inwards /etc/hostname. practise goodness of using `hostname` is that you lot tin dismiss exactly re-create as well as run this ascendency on whatever host without typing hostname past times yourself. This is ane of many non bad usage of grep inwards UNIX, encounter 10 ways to purpose grep ascendency inwards UNIX to discovery out why grep is ane of the most useful ascendency inwards UNIX.

# grep `hostname` /etc/hosts
192.52.32.15     nyk4035        nyk4035.unix.com

ping ascendency example
How to discovery IP address of whatever host inwards a UNIX based organization Unix ascendency to discovery IP address from hostname - Linux exampleOur patently quondam ping ascendency tin dismiss too last used to discovery IP address of localhost or whatever other host provided you lot know the hostname. ping is used to cheque wither target server is last or non but piece using amongst selection -s it too display IP address of corresponding host every bit well. Ping is genuinely ane of the of 10 useful networking ascendency inwards UNIX , encounter that link for other commands.

# ping -s `hostname`
PING nyk4035: 56 information bytes
64 bytes from nyk4035 (192.52.32.15): icmp_seq=0. time=0.186 ms

nslookup ascendency example
nslookup is ane of the principal UNIX ascendency to find IP address from hostname as well as in ane trial again from hostname to IP address. Similar to ping you lot tin dismiss too purpose nslookup ascendency to discovery IP address of both local host as well as remote host inwards whatever UNIX based system. nslookup is by as well as large available inwards most of UNIX based organization e.g. Linux, Solaris, IBM AIX or whatever other UNIX system.

# nslookup `hostname`
nyk4035.unix.com       canonical mention = nyk4035.unix.com
Name:   nyk4035.unix.com
Address: 192.52.32.15

That's all on How to discovery IP address inwards UNIX , Linux as well as other UNIX based system e.g. Solaris, IBM AIX, BSD etc. We convey seen examples of getting IP address from hostname past times using ipconfig, ping, hostname as well as nslookup command. If ane ascendency is non working inwards your machine you lot tin dismiss ever purpose other ascendency or you lot tin dismiss only cross cheque IP address past times using multiple UNIX commands.

Further Learning
Linux Command Line Basics
10 chmod ascendency event inwards UNIX as well as Linux

Wednesday, December 11, 2019

What Is Deviation Betwixt Difficult Link As Well As Soft Link Inwards Unix?

There are 2 types of links inwards UNIX system, difficult link as well as soft links, too known equally symbolic link or symlink. Though both points to around other source, in that place are a lot of departure betwixt them. difficult link is conduct pointer to the inode of the master file. If you lot compare the master file amongst the difficult link in that place won't hold upwardly whatsoever differences betwixt them. On other hand, a soft link is a file that accept the information to indicate to around other file or inode. That inode points to the information inwards the disk. Hard links are much to a greater extent than restrictive than soft links as well as that's why they are used rarely. Also non all file systems supports difficult links precisely UNIX does. Earlier Windows file organisation doesn't back upwardly soft links precisely from Windows 2000 onward they are supporting it, both Windows Vista as well as Windows vii back upwardly links now. MS DOS operating organisation doesn't back upwardly neither difficult link nor soft link. You tin utilisation ln ascendence inwards UNIX to create, update as well as take away soft links. I frequently utilisation links for laid as well as unloosen administration operate e.g. our application never points to hard-coded file or directory instead it points to links which is updated on every release.



Difference betwixt Soft link as well as Hard link inwards UNIX

Here are duad of of import differences betwixt difficult link as well as soft link inwards UNIX :


1) The target of the the difficult link must exist, which is non mandatory inwards illustration of soft link. Influenza A virus subtype H5N1 soft link is said broken if target link doesn't exists.

2) Unlike soft link which are mostly created to reference directories e.g. electrical flow link pointing to latest release, Hard links are mostly non allowed on directories.

3) One to a greater extent than critical departure betwixt soft link as well as Hard link is that difficult links are non allowed to cross partitions or volumes. Therefore, they cannot be across file systems.

4) Influenza A virus subtype H5N1 difficult link looks, as well as behaves, similar a regular file, then they tin hold upwardly difficult to find. On the other mitt soft links are quite dissimilar than regular files.

5) Influenza A virus subtype H5N1 difficult link is, for all intents as well as purposes, the same entity equally the master file. They accept the same file permissions, fourth dimension stamps, as well as then on. All attributes are identical.


Difference betwixt difficult as well as soft link is too ane of the popular Linux as well as UNIX Interview question, then knowing departure volition too aid you lot on interviews.  BTW, A moving-picture present is worth a thou words as well as this is truthful inwards connectedness amongst this image. You tin encounter that how difficult link as well as soft link are dissimilar to each other, difficult link conduct indicate to file

 There are 2 types of links inwards UNIX organisation What is departure betwixt difficult link as well as soft link inwards UNIX?



That's all near difference betwixt difficult link as well as soft link inwards UNIX. Because of these restrictions, difficult links are non used equally frequently equally symbolic links. I accept withal to notice a adept argue to utilisation difficult link precisely I accept been using soft links from long fourth dimension for starting our Java application. It's much to a greater extent than flexible to refer links inwards compaction script than difficult coded files as well as directory names.

Here are duad of to a greater extent than UNIX Interview questions as well as articles from this spider web log :
  • How produce you lot notice symbolic links inwards a directory inwards UNIX? (answer)
  • How to notice hostname from IP address inwards UNIX? (answer)
  • How to notice swap infinite as well as usage inwards Solaris? (answer)
  • How to take away empty files as well as directory inwards UNIX? (answer)
  • How to notice size of a directory including all files as well as sub-directory? (answer)

Further Learning
Linux Command Line Basics
Linux Command Line Interface (CLI) Fundamentals
Learn Linux inwards v Days as well as Level Up Your Career

Saturday, November 9, 2019

10 Linux As Well As Unix Interview Questions As Well As Answers Asked Inwards Wipro Tcs Capegemini

UNIX in addition to Linux Interview Questions in addition to Answers
Questions from diverse UNIX operating systems e.g. Solaris, Linux, IBM AIX or whatever other UNIX operating organisation is asked on dissimilar back upward in addition to programming interviews. I select e'er seen few interview questions from Linux in addition to UNIX along alongside SQL inwards almost every Java programming interviews. You only tin non afford non to gear upward questions from UNIX in addition to Linux until your Job absolutely doesn't require whatever run inwards UNIX operating system. I select collected many UNIX ascendency interview questions in addition to already shared them but I flora that except organisation admin jobs, many programming labor interviews alone focus on full general UNIX commands e.g. chmod, find or grep in addition to fundamentals similar finding files in addition to directories, managing file space, networking commands, checking procedure condition in addition to managing file permissions.

In this article, nosotros volition meet such form of often asked interview questions in addition to answers from UNIX in addition to Linux operating System. Questions are real key inwards nature in addition to non express to Linux alone in addition to every bit applicable to other UNIX operating systems e.g. Solaris, IBM AIX etc. 

Many of these UNIX questions are asked during diverse interviews on companies similar TCS, Infosys, Citibank , Wipro, Capgemini in addition to Tech Mahindra. As I said they are real key in addition to tin endure asked inwards whatever company.  If you lot come upward across whatever other often asked Linux questions which are non on this listing experience complimentary to suggest.




UNIX in addition to Linux Interview Questions in addition to Answers

UNIX in addition to Linux Interview Questions in addition to Answers 10 Linux in addition to UNIX Interview Questions in addition to Answers asked inwards Wipro TCS CapegeminiHere is my listing of often asked UNIX in addition to Linux interview questions in addition to answers. All these questions are based upon key commands in addition to concepts which are a must for working on whatever UNIX operating organisation e.g. Solaris.


1) How to uncovering all the links inwards a folder inwards UNIX or Linux ?
This is a tricky UNIX question as in that place is no specific ascendency to uncovering all symbolic links. Though you lot select ln ascendency for creating in addition to updating soft links but nada which gives you lot all the links inwards a directory. You demand to purpose ls ascendency which lists everything inwards the directory in addition to hence you lot demand to listing all the links, as they start alongside "l" as get-go characters, as shown inwards in a higher identify article .

here is the actual UNIX ascendency to uncovering all links inwards a directory :

linux@nyj872:  ls -lrt total 2.0K -rw-r--r--  1 Linux Domain Users  0 December  six  2011 a drwxr-xr-x+ 1 Linux Domain Users  0 Sep 19 12:30 java/ lrwxrwxrwx  1 Linux Domain Users  4 Sep 19 12:31 version_1.0 -> java/  linux@nyj872:  ls -lrt | grep '^l' lrwxrwxrwx  1 Linux Domain Users  4 Sep 19 12:31 version_1.0 -> java/



2) How to uncovering a procedure in addition to kill that?
Another classic UNIX interview questions. Answer of this enquiry is unproblematic if you lot are familiar alongside ps, grep in addition to kill command. past times using "ps -ef" you lot tin acquire a listing of all procedure in addition to hence purpose grep to uncovering your procedure in addition to acquire the PID of that process. Once you lot got PID you lot tin purpose the kill ascendency to kill that procedure as shown inwards this example of kill ascendency inwards UNIX.



3) How to run a computer program inwards the background inwards UNIX or Linux ?
an slowly UNIX or Linux interview question, alone when you lot know. You tin purpose & to run whatever procedure inwards the background in addition to hence you lot tin purpose jobs to uncovering the labor id for that procedure in addition to tin purpose  fg in addition to bg ascendency to convey that procedure into foreground in addition to background. See how Linux works to acquire to a greater extent than nearly running a procedure inwards the background.


UNIX in addition to Linux Interview Questions in addition to Answers 10 Linux in addition to UNIX Interview Questions in addition to Answers asked inwards Wipro TCS Capegemini




4) How to sort the output of a ascendency inwards opposite guild inwards Linux or UNIX ?
One to a greater extent than Linux commands interview enquiry which checks cognition of often used command. you lot tin purpose sort ascendency inwards UNIX to sort the output of whatever ascendency past times using PIPE. By using -r selection alongside sort ascendency you lot tin sort the output of whatever ascendency inwards opposite order. See these sort ascendency examples for to a greater extent than details.



5) How to practise an archive file inwards UNIX or Linux Operating System ?
Another interview enquiry based on cognition of UNIX or Linux command. you lot tin purpose the tar command to slap-up archives inwards UNIX or Linux. you lot tin fifty-fifty combine tar in addition to gzip to practise a compressed archive inwards UNIX.



6) What is the pregnant of a file has 644 permission ?
To respond this UNIX or Linux interview question, you lot must know basics of files in addition to directories inwards UNIX.  The 644 represents permission 110 for the owner, permission 100 for grouping in addition to 100 for others which way read + write for an possessor who creates that file in addition to read alone permission for grouping in addition to others. 

You tin besides meet The Linux Command Line: H5N1 Complete Introduction, a mass to acquire to a greater extent than nearly essential compaction commands inwards Linux.


UNIX in addition to Linux Interview Questions in addition to Answers 10 Linux in addition to UNIX Interview Questions in addition to Answers asked inwards Wipro TCS Capegemini




7) How volition you lot withdraw empty files or directories from /tmp ?
You tin purpose the find ascendency to uncovering all the empty files in addition to directory in addition to hence combine the output alongside xargs ascendency to withdraw all empty files from /tmp or whatever other directory inwards UNIX. See how to delete empty directory in addition to files inwards UNIX  for exact ascendency in addition to to respond this UNIX ascendency interview questions inwards detail.



8) I select read permission on a directory but I am non able to acquire inwards it why ?
One to a greater extent than tricky UNIX questions. In guild to acquire into a directory, you lot demand to execute permission. if your directory does non select to execute permission hence you lot tin non become into that directory past times using the cd command. read UNIX files in addition to directory permissions for to a greater extent than information.



9) How practise you lot uncovering all files which are modified 10 minutes earlier ?
This is some other the Linux interview questions from often used ascendency e.g. uncovering in addition to grep. you lot tin use -mtime option of the uncovering ascendency to listing all the files which are modified 10 or m minutes before. meet these find ascendency examples for to a greater extent than details.



10) How to practise you lot uncovering the size of directory inwards UNIX or Linux ?
This is some other tricky in addition to fighting tough Linux interview enquiry as pop ls ascendency doesn't demonstrate the consummate size of directories inwards UNIX. you lot demand to purpose du ascendency to acquire a total size of directories including all subdirectories inwards UNIX. See How to uncovering directory size inwards UNIX for exact ascendency in addition to detailed explanation.

You tin besides depository fiscal establishment jibe out Practical Guide to Linux Commands, Editors, in addition to Shell Programming to acquire to a greater extent than nearly essential Linux commands. One of the best mass on Linux.


UNIX in addition to Linux Interview Questions in addition to Answers 10 Linux in addition to UNIX Interview Questions in addition to Answers asked inwards Wipro TCS Capegemini




11) How practise  you uncovering all the procedure listening on a exceptional port inwards Linux?
You tin purpose the netstat ascendency to uncovering all the procedure which are listening on a exceptional port as shown below:


$ netstat -nap | grep 8084 (Not all processes could endure identified, non-owned procedure information volition not endure shown, you lot would select to endure source to meet it all.) tcp 0 0 0.0.0.0:8084 0.0.0.0:* LISTEN 25314/java

Here 25314 is the procedure id of a tomcat server running on Linux. Since tomcat is a Java spider web application it started alongside coffee ascendency in addition to that's why you lot meet 25314/java. See here to acquire to a greater extent than nearly netstat ascendency inwards UNIX.



12) How to you lot uncovering all the procedure which has opened a file inwards Linux?
You tin purpose the lsof (list opened upward files) ascendency to uncovering out the procedure which has a file handgrip on the exceptional file. It's real useful ascendency to depository fiscal establishment jibe which procedure are reading a file. You tin purpose lsof ascendency as shown below to uncovering out all the process:


$ lsof /home/someuser/somefile


will listing all the procedure which has opened this file. you lot tin meet the command, PID, user in addition to total file path to uncovering out the process. See here to acquire to a greater extent than nearly the lsof ascendency inwards Linux.


UNIX in addition to Linux Interview Questions in addition to Answers 10 Linux in addition to UNIX Interview Questions in addition to Answers asked inwards Wipro TCS Capegemini


13) How to mail HTTP asking from a Linux server?
You tin purpose either wget or scroll ascendency to mail HTTP request, both GET in addition to POST from a Linux auto as shown below:


$ scroll http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=bd82977b86bf27fb59a04b61b657fb6f {"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":804,"main":"Clouds", "description":"overcast clouds","icon":"04n"}],"base":"stations", "main":{"temp":282,"pressure":1022,"humidity":87,"temp_min":277.15, "temp_max":285.15},"visibility":10000,"wind":{"speed":1.5}, "clouds":{"all":90},"dt":1445577409,"sys":{"type":1,"id":5093, "message":0.0201,"country":"GB","sunrise":1445582275,"sunset":1445619056}, "id":2643743,"name":"London","cod":200} 

Here nosotros select sent a GET asking to /search?q=10-xargs-command-example-in-linux-unix">here to acquire to a greater extent than nearly scroll ascendency inwards UNIX.



14) How practise you lot practise a total directory construction e.g. /parent/child/grandchild inwards UNIX?
Well, you lot tin purpose the mkdir ascendency alongside option -p to practise all raise directories inwards 1 become as shown below:


[#  ]$ mkdir -p software/java/app/config [#  ]$ [#  ]$ pwd /home/john [#  ]$ cd software/java/app/config/ [#  /software/java/app/config]$

You tin meet hither software/java/app/config directory is created inwards only 1 command. See here to acquire to a greater extent than about mkdir ascendency inwards UNIX



15) How practise you lot edit a large text file inwards UNIX without opening it?
You tin purpose the sed command to edit a large file inwards UNIX without opening it. The sed stands for flow editor in addition to you lot tin practise uncovering supplant inwards a file as shown below:


$ sed 's/Apple/Microsoft/' bestphone.txt


This ascendency volition uncovering "Apple" inwards line in addition to supplant it alongside "Microsoft" string inwards the file bestphone.txt.


These were some of the frequently asked UNIX in addition to Linux ascendency interview questions in addition to answers which look inwards many information technology Job interview which requires cognition of UNIX operating system, Including programming labor interviews e.g. core Java in addition to J2EE interviews. Questions from UNIX in addition to Linux is besides real pop during C in addition to C++ programming interviews.

Further Learning
Linux Command Line Basics
Linux Command Line Interface (CLI) Fundamentals
Learn Linux inwards v Days in addition to Level Up Your Career

Friday, November 8, 2019

Find + Du Ascendency Example Linux - How To Search/Print Large Files In Addition To Directories Amongst Size To Gratuitous Disk Space?

One of the mutual occupation spell working inward Linux is to find large files to complimentary around space. Suppose, your file arrangement is amount together with yous are receiving an warning to take away spaces or if your host is run out of infinite together with your server is non starting up, the offset thing yous produce is find transcend 10 largest files together with run into if yous tin delete them. Usually, onetime files, large Java heap dumps are skillful candidates for removal together with freeing upwards around space. If yous are running Java application e.g. heart Java-based programs or spider web application running on Tomcat together with then yous tin take away those heap dump files together with complimentary around space, but the large enquiry is how produce yous detect those? How produce yous know the size of the biggest file inward your file system, peculiarly if yous don't know which directory it is? We'll travail to detect answers for around of those questions inward this article.

When I was novel to Linux, I don't bring whatever other alternative but to acquire to the log directory together with await for onetime files which are larger alongside residual together with delete them. They worked good until one 24-hour interval our server died due to a huge cache file.

I wasn't able to locate that because it wasn't inward the log directory, together with then I come upwards to know near the find command which allow yous search sub-directories for large files equally shown below:

$ detect . -size +1G

This ascendance volition impress all the files which are greater than 1GB from electrical flow directory together with whatever subdirectory.

The exclusively occupation with this 1 is that it doesn't impress the exact size. The occupation was solved past times using the  -printf option, which allows yous to specify a format String much similar Java's printf() method.



1.  Finding Big files using detect ascendance inward Linux

You tin farther tweak the ascendance to detect files up-to for sure size e.g. below ascendance volition detect all files.  Here is the modified UNIX ascendance to detect large files with size :

$ detect . -size +1G -printf '%s %p\n'

hither is %s is for size together with %p are for the path.

Alternatively, You tin besides use -exec alternative to run ls on each file the detect ascendance furnish to impress its size equally shown below:

$ detect . -size +100M -exec ls -sh {} \;

This is skillful enough, yous tin simply run into which files yous tin delete together with complimentary around space, but occupation is that yous volition non detect whatever file which is larger than 1GB, thus I e'er purpose this ascendance with around hypothetical large release e.g. 10GB etc, but, those are simply workaround, non the proper fix. Let's run into what nosotros tin produce next.

Btw, if yous are novel to detect together with then I propose yous acquire familiar with its dissimilar alternative equally it's a really of import together with powerful command. I propose yous check  Linux Interview questions, so if yous know this play a joke on yous reply this enquiry on interviews equally well. 

As I bring said, a skillful noesis of diverse Linux commands is really of import for a programmer working inward a Linux machine. I know yous tin e'er Google things but yous bring to know what to Google together with that's why basic information near diverse Linux ascendance is essential.

If yous experience that yous don't know plenty Linux commands together with then yous tin bring together a comprehensive course of written report like Linux Command Line Basics to acquire concur of the Linux commands which affair most.


 One of the mutual occupation spell working inward Linux is to  detect + du ascendance instance Linux - How to search/print large files together with directories with size to complimentary disk space?



That's all near how to detect the large files together with directories inward Linux. As I said, before I used to search large files past times using detect ascendance with -size alternative but that is to a greater extent than or less a guesswork because yous never know the size of the largest file inward a machine, but past times using a reasonable high size, yous tin perhaps detect all large files inward your filesystem.

One to a greater extent than ascendance yous tin purpose to detect the large files with size inward Linux is the disk usage or du command, which volition besides listing both files together with directories.


Further Learning
Learn Linux inward v Days together with Level Up Your Career
10 instance of networking ascendance inward Unix
10 Example of tar commands inward Unix
5 Example of kill commands inward Unix together with Linux
VI Editor examples together with tips for beginners
The Linux Command Line: H5N1 Complete Introduction

Thanks a lot for reading this article so far. If yous similar this UNIX ascendance tips together with then delight part with your friends together with colleagues. If yous bring whatever enquiry or comment together with then delight drib a comment


Grep Ascendence Example Inward Linux - How To Search All Files Matching Specific Text

One of the most mutual chore spell working inward programming projects is finding files containing only about specific text e.g. y'all bring your application deployed inward Linux server as well as y'all are migrating your database from 1 server to another. Now, y'all desire to file all config files as well as scripts which are referencing your onetime database using the hostname or IP address, therefore that y'all tin supersede them alongside an alias. Well, y'all should ever work an alias to connect to the database or whatever other system, but sometimes it happens y'all bring to work hostname. Anyway, how create y'all uncovering all those files containing hostname inward your Linux machine? Well, the grep ascendancy is hither to assist you.

The grep command allows y'all to scan files to uncovering whatever matching text as well as y'all tin work the recursive selection of grep ascendancy to uncovering all files containing a reference to your onetime database hostnames, or specific text inward general.

You tin combine recursive selection alongside ignore instance selection (-i) to uncovering a specific text similar hostname by ignoring instance inward your config files as well as scripts.

This is the ascendancy I often work to search all files inward dissimilar sub-directories for finding reference to a specific text e.g. a hostname which is going to decommission or needs to hold upward migrated:

$ grep -iR text *

The -R selection volition recursively search files inward sub-directories starting from the electrical flow directory as well as -i volition search for the text you're render ignoring case.

Btw, if y'all are non familiar alongside basic Linux commands similar grep, find, chmod etc therefore I propose y'all to root become through a primal course of written report like Linux Command Line Basics on Udemy. This volition assist y'all to acquire to a greater extent than inward a brusque time.




The grep ascendancy to uncovering all files containing specific text inward Linux

By default grep volition impress both the matching text every bit good every bit the advert of the file containing matching text, if y'all are only interested inward file names therefore y'all tin also work the grep ascendancy alongside selection -l every bit shown below:

$ grep -iRl text *

Here is an illustration of the recursive search alongside grep ascendancy which prints both file as well as matching text as well as alone file names:

 One of the most mutual chore spell working inward programming projects is finding files contai GREP Command Example inward Linux - How to Search All Files Matching Specific Text



If y'all also desire to search for the whole word, instead of only matching a role of the text, therefore y'all drive add together selection -w, which matches the whole give-and-take like

$grep -iRlw '-Xms' *

volition search for exact "-Xms" text inward all files, it is could to uncovering the scripts where y'all are specifying your JVM arguments.

You tin also work options similar --exclude, --include, --exclude-dir, as well as --include-dir for to a greater extent than efficient as well as fast searching. For example, the next ascendancy volition alone search for text inward Java files:

$ grep --include=\*.java -iRw text *

You tin fifty-fifty work the regular expression to render for a to a greater extent than sophisticated search similar the next ascendancy volition search for specified text on .c as well as .h files

$ grep --include=\*.{c,h} -iRw text *

This ascendancy volition exclude searching all the files ending alongside .svn extension:

$ grep --exclude=*.svn -iRw '/path/to/file/' -e "pattern"


As I bring said before, It's non only of import to acquire novel commands but also novel options of the ascendancy y'all are familiar alongside to brand the most of Linux power. If y'all desire to ameliorate your Linux skills I propose y'all become through 




Important Points to Remember

1) The grep -r or -R selection is used for recursive search

2) The grep -w is used for give-and-take search i.e. it volition check to the exact word

3) The grep -i is used for ignoring instance search e..g it volition check to "Java", "JAVA", "javA" as well as other variants.

4) The grep --include is used to search alone for sure enough types of files.

5) The grep --exclude is used to exclude non-interesting files e.g. log files or .svn files.


That's all close how to search for matching text inward all files inward UNIX as well as Linux. This ascendancy is really powerful as well as 1 of the useful tool to uncovering out files referencing straight hostnames instead of aliases. They are really useful for host migrations as well as database migration. You tin fifty-fifty work them spell troubleshooting issues.


Further Learning
Linux Command Line Basics
example)
  • 10 Example of tar commands inward Unix (example)
  • 5 Example of kill commands inward Unix as well as Linux (example)
  • VI Editor examples as well as tips for beginners (example)
  • How to work the netstat ascendancy to uncovering which procedure is listening on a port? (example)
  • How does nslookup ascendancy operate inward UNIX? (answer)
  • 10 examples of lsof ascendancy inward Linux? (examples)
  • 10 books to acquire essential commands of Linux or UNIX? (list)
  • How Linux works? What Every SuperUser should know? (book)
  • 10 Examples of cURL ascendancy inward Linux? (examples)
  • How to work the CUT ascendancy inward Linux (tutorial)
  • How to move out from the telnet ascendancy inward UNIX? (example)
  • How to mail HTTP asking to telephone telephone a spider web service from the ascendancy business inward Linux? (example)

  • Thanks for reading this article therefore far. If y'all similar this article therefore delight portion alongside your friends as well as colleagues. If y'all bring whatever interrogation or feedback therefore delight drib a comment.

    P. S. - If y'all are looking only about gratis courses to acquire or ameliorate your Linux skills y'all should depository fiscal establishment check out this listing of Free Linux Courses for Programmers as well as Developers.

    Linux Mailx + Mutt Ascendence Examples - Iv Ways To Ship E-Mail Alongside Attachment From Rhel V As Well As Half-Dozen Server

    One of the mutual chore for programmers working inwards Linux machine is to shipping emails, for example, your Java applications are running on Linux similar RHEL v or RHEL vi version together with you lot quest to shipping a written report of all the clients connecting to your application. An slow means to achieve this is to write a shell script, which volition dump all clients inwards the log file together with so operate grep command together with generate a report. If you lot have got to grep logs from multiple hosts, you lot tin too operate the SSH ascendency to run the same ascendency on multiple hosts. Once you lot have got got the listing of clients connecting to your application, you lot tin exactly shipping the CSV file to yourself inwards an electronic mail or to your application DL, or a grouping of users you lot desire to.

    Now, the query is how to shipping an electronic mail from Linux? together with to a greater extent than importantly how to shipping an electronic mail alongside attachments? Well, in that location are unlike options based on whether you lot are running on RHEL v or RHEL 6.

    For example, my favorite means to shipping an electronic mail alongside attachment was yesteryear using the uuencode together with mail ascendency but, unfortunately, that didn't piece of work when nosotros migrated to RHEL 6. So, I had to operate the mailx command alongside -a flag for attachments.

    But, mailx is non the alone means to shipping electronic mail from Linux, you lot tin too operate the mutt ascendency if its available to you.

    In this article, I'll demo you how to shipping an electronic mail alongside trunk together with attachment using mailx together with mutt ascendency from a Linux host. 

    There may live on a duo of to a greater extent than options but I haven't explored much, for me these ii industrial plant fine inwards both RHEL v together with RHEL vi hosts together with I was able to complete my scripts alongside these ii commands. I'll explore to a greater extent than when I acquire roughly fourth dimension but if you lot have got roughly thoughts experience gratis to percentage alongside us together with if you lot desire to larn more, I propose you lot acquire through Linux Administration Bootcamp course on Udemy.




    How to shipping an electronic mail alongside trunk together with attachment from Linux

    I by together with large operate mailx for sending emails, therefore most of the examples are of mailx command. It's too of import to know the syntax of the mailx command, which volition attention you lot to empathise the examples every bit nosotros motion 1 measurement at a time.

    Syntax of mailx ascendency :

    mailx -eiIUdEFntBDNHRV -T FILE -u USER -h hops -r address -s SUBJECT -a FILE -q FILE -f FILE -A ACCOUNT -b USERS -c USERS -S OPTION users

    You tin run into that -s is used for a plain of study together with -a is used for attachment. You tin too CC users using -c options together with BCC users using -b option.

    Now, 1 question, which may come upward to your heed is what would live on the sender's electronic mail address when you lot shipping post service from Linux? Well, it depends on the user who is sending an email.

    For example, if you lot log inwards using your personal operate together with shipping post service so it would live on your electronic mail but if you lot log inwards every bit application user together with shipping an electronic mail so it would live on the electronic mail configured for that application user account.


    Example 1 - Sending electronic mail from Linux

    If you lot exactly desire to shipping a unproblematic electronic mail e.g. without attachment, you lot tin exactly operate the mailx ascendency to produce that.

    $ mailx -s "test" abc@gmail.com
    This is unproblematic electronic mail without attachment
    EOT

    This volition shipping a shipping an electronic mail alongside plain of study every bit "test" to recipient abc@gmail.com. Once you lot type this ascendency it volition inquire you lot to type the content inwards the body. Once you lot are done, you lot tin press the Ctrl + D to halt the typing together with it volition shipping the email.

    Btw, If you lot are non familiar alongside Linux operating organization together with compaction itself then Learn Linux inwards v Days together with Level Up Your Career on Udemy is a expert place, to get down with.

     One of the mutual chore for programmers working inwards Linux machine is to shipping emails Linux mailx  + mutt ascendency Examples - four ways to shipping Email alongside Attachment from RHEL v together with vi Server


    Example 2 - Writing trunk using echo

    In the concluding example, you lot quest to write the content of the trunk together with so press the Ctrl + D to shipping the email, but if you lot already have got a message written you lot tin too operate echo ascendency along alongside mailx to shipping the electronic mail directly.

    The output of echo tin live on used every bit the trunk every bit shown below:

    $ echo "testing" | mailx -s "test" abc@gmail.com

    This fourth dimension mailx volition non hold off for your input together with volition straight shipping the electronic mail alongside text "texting" inwards the body.

    Btw, if you lot are non familiar alongside essential Linux commands together with compaction built-ins similar echo so I propose you lot to commencement acquire through  Learn Basic Commands inwards Linux Shell to familiarize yourself alongside these basics commands.




    Example iii - Email alongside Attachment from Linux

    This is the most pop operate of mailx ascendency for me. I ever detect using this pick live on it sending a file from Linux host to my windows host or writing scripts which sends electronic mail from a Linux machine. Until RHEL 5, my favorite means to shipping an attachment inwards the electronic mail was yesteryear using the uuencode ascendency e.g.

    $ gzip -c log.txt | uuencode log.gz | post service -s "log file for `date`" abc@gmail.com


    This ascendency volition commencement compress the log.txt together with so volition shipping every bit attachment log.gz alongside plain of study "log file for a date" to abc@gmail.com, hither appointment volition live on replaced yesteryear electrical flow appointment because nosotros have got used `date`, which volition execute the appointment ascendency together with position its output here.

    The gzip -c command writes output to measure output piece keeping the master copy files unchanged i.e. non changing it every bit log.gz, which it does without -c option. If you lot desire to larn to a greater extent than virtually gzip together with other compression together with archiving ascendency so banking concern fit out the  Linux Command Line Basics course of teaching on Udemy.  It's available inwards exactly $9.99 inwards Udemy's flash sale.

     One of the mutual chore for programmers working inwards Linux machine is to shipping emails Linux mailx  + mutt ascendency Examples - four ways to shipping Email alongside Attachment from RHEL v together with vi Server


    This ascendency has served me good for a long fourth dimension but unfortunately, it doesn't piece of work inwards RHEL vi hosts. If you lot travail that ascendency on an RHEL vi hosts, instead of receiving an attachment, you lot volition have roughly gibberish inwards electronic mail trunk alongside no attachment.

    So, how produce nosotros solve this problem? Is in that location whatsoever other means to shipping an electronic mail to attachment from RHEL vi hosts? Well, yes, we'll operate the mailx ascendency alongside -a flag, which is used to attach a file.

    Here is the event of a mailx ascendency to shipping a file every bit an attachment to RHEL vi servers:

    $ echo "mailx industrial plant fine inwards RHEL 6" | mailx -s "texting" -a log.gz abc@gmail.com

    This volition shipping an electronic mail alongside the trunk every bit "mailx industrial plant fine inwards RHEL 6" together with attachment every bit log.gz alongside the plain of study job every bit "texting".



    Example four - Adding a User together with CC together with BCC

    If you lot have got to include other electronic mail address or user every bit CC or BCC piece sending reports from Linux so you lot tin operate the mailx -c together with mailx -b for adding users every bit shown inwards the next example:

    $ echo "message" | mailx -s "test" -c group@gmail.com -b admin@gmail.com abc@gmail.com

    This electronic mail volition live on sent to abc@gmail.com together with cc'd to group@gmail.com together with BCC to admin@gmail.com

    The mailx command has several to a greater extent than options but I didn't quest whatsoever to a greater extent than other than these. If you lot desire to explore, you lot tin operate information mailx ascendency to acquire to a greater extent than information virtually mailx. If you lot desire to larn to a greater extent than you lot tin too take Crontab example)
  • 10 event of Networking commands inwards Unix (nslookup)
  • 5 Example of kill commands inwards Unix together with Linux (example)
  • VI Editor examples together with tips for beginners (vi examples)
  • How does nslookup ascendency piece of work inwards UNIX? (answer)
  • 10 examples of lsof ascendency inwards Linux? (examples)
  • How to operate the netstat ascendency to detect which procedure is listening on a port? (example)
  • Linux detect + du + grep event (example)
  • 10 Examples of gyre ascendency inwards Linux (cURL)
  • 10 Examples of chmod ascendency inwards Linux (chmod)
  • A Practical Guide to Linux Commands, Editors, together with Shell Programming (guide)

  • Thanks for reading this article so far. If you lot similar this article together with my explanation of sending electronic mail from a Linux machine so delight percentage alongside your friends together with colleagues.

    P. S. - If you lot are looking for roughly gratis online courses to start your Linux journey, you lot should banking concern fit out my listing of Free Linux Courses for Programmers, information technology Professionals, together with System Administrators.