Most Popular
1500 questions
99
votes
20 answers
What's the easiest way to find an unused local port?
What's the easiest way to find an unused local port?
Currently I'm using something similar to this:
port=$RANDOM
quit=0
while [ "$quit" -ne 1 ]; do
netstat -a | grep $port >> /dev/null
if [ $? -gt 0 ]; then
quit=1
else
port=`expr…

mybuddymichael
- 1,145
99
votes
9 answers
How to see disk details like manufacturer in Linux
With sfdisk -s I can see the disk capacity as follows:
$ sfdisk -s
/dev/cciss/c0d0: 143338560
total: 143338560 blocks
How do I see disk details like disk manufacturer? I tried hdparm, but got an error:
$ hdparm -i …
user3266
99
votes
7 answers
Is there a simple command for outputting tab-delimited columns?
E.g. I have a file (produced with echo -e "var1\tvar2\t\var3\tvar4" > foo) that are output as:
$ cat foo
case elems meshing nlsys
uniform 2350 0.076662 2.78
non-conformal 348 0.013332 0.55
scale 318 0.013333 …

Sebastian
- 8,817
- 4
- 40
- 49
99
votes
2 answers
What does "set --" do in this Dockerfile entrypoint?
I'm trying to understand what this Docker entrypoint does.
It seems to me that's a very common pattern when writing Dockerfiles, but my bash skills are limited and I have no idea of all the special bash symbols kung fu.
Also, it's hard to google…

Lucas Pottersky
- 1,093
99
votes
6 answers
How to copy a directory recursively using hardlinks for each file
I want to create a "copy" of a directory tree where each file is a hardlink to the original file
Example: I have a directory structure:
dirA/
dirA/file1
dirA/x/
dirA/x/file2
dirA/y/
dirA/y/file3
Here is the expected result, a "copy" of the…

Gudmundur Orn
- 2,121
99
votes
5 answers
How can I verify SSL certificates on the command line?
I'm trying to validate/verify that the rsa key, ca-bundle, and certificate stored here are ok. They are not being served by a webserver. How can I verify them?

xenoterracide
- 59,188
- 74
- 187
- 252
99
votes
5 answers
How to create a simple .txt (text) file using terminal?
I'm just trying to review basic terminal commands. Having said that, how do I create a text file using the terminal only?

Mike Wentworth
- 1,213
99
votes
13 answers
Meaning of “Connection closed by xxx [preauth]” in sshd logs
We have a Windows batch script, which connects automatically to a linux server via PLINK (putty). There is NO public private key authentication, the user and the password are in
the script.
On our linux server we have several sshd log entries…

Wolfgang Adamec
- 1,383
98
votes
2 answers
Is there an easy way to "restart" a tmux pane?
Assume I have a tmux (1.7) window split as follows:
________________________
| 1 |
| |
|-----------+------------|
| 2 | 3 |
|___________|____________|
Now, the vertical sizes have been…

0xC0000022L
- 16,593
98
votes
2 answers
Reading grep patterns from a file
I have a couple of big text files and in the file UNIQS.txt I have a list of strings to grep from another file. The code I use is
grep -f UNIQS.txt EEP_VSL.uniqs.sam > UNIQ_templates.sam
which does nothing - the file generated is empty. But when I…

Stiofán Fordham
- 1,165
98
votes
9 answers
How to insert the result of a command into the text in vim?
For instance, :echo strftime(%c) will show the current time on the bottom, but how to insert this time string into the text (right after the cursor)?

xzhu
- 1,362
98
votes
10 answers
How to terminate dead connections from the command line without restarting server
I have some dead connections in an application which enter a hanged state if the client machine is dead. One of the connections is shown as
->192.168.1.214:49029 (ESTABLISHED)
Is there a way to terminate these connections from the Linux command…

Vivek Goel
- 1,293
98
votes
2 answers
What does the Chromium option `--no-sandbox` mean?
I'm running Chromium like so : chromium --no-sandbox
I'm doing this because I'm running Debian Squeeze on an OpenVZ VM Container and it's the only way I can get it to work.
Though I keep reading this is terrible. But I want to know why exactly. Can…

capdragon
- 1,187
98
votes
12 answers
How do I count all the files recursively through directories
I want to see how many files are in subdirectories to find out where all the inode usage is on the system. Kind of like I would do this for space usage
du -sh /*
which will give me the space used in the directories off of root, but in this case I…

xenoterracide
- 59,188
- 74
- 187
- 252
98
votes
6 answers
Create partition aligned using parted
I'm partitioning a non-SSD hard disk with parted because I want a GPT partition table.
parted /dev/sda mklabel gpt
Now, I'm trying to create the partitions correctly aligned so I use the following command to know where the first sector…

Marc
- 1,721