Most Popular
1500 questions
105
votes
15 answers
How can I remove duplicates in my .bash_history, preserving order?
I really enjoying using control+r to recursively search my command history. I've found a few good options I like to use with it:
# ignore duplicate commands, ignore commands starting with a space
export HISTCONTROL=erasedups:ignorespace
# keep the…

cwd
- 45,389
105
votes
8 answers
Using rsync to move (not copy) files between directories?
I have been using rsync to copy files for some time. My understanding is that rsync is faster than cp when some of the files to transfer are already in the destination directory, transferring only the incremental difference (i.e. the "deltas").
If…

Amelio Vazquez-Reina
- 41,161
105
votes
1 answer
Chrome: DNS requests with random DNS names: malware?
Over the years (since 2005), I have seen logs of strange random DNS requests done, on the multiple DNS / BIND servers I have maintained.
May 7 12:13:50 1.1.1.1 named[63742]: client 1.1.1.2#24123 (verxkgiicjmcnxg): view internal: query:…

Rui F Ribeiro
- 56,709
- 26
- 150
- 232
105
votes
2 answers
Difference between .xinitrc, .xsession and .xsessionrc
I found three configuration files.
.xinitrc
.xsession
.xsessionrc
I know that the first one is for using startx and the second and third are used when using a display manager. But what is the difference between the last two?

lockdoc
- 1,191
105
votes
8 answers
Why would I tar a single file?
At my company, we download a local development database snapshot as a db.dump.tar.gz file. The compression makes sense, but the tarball only contains a single file (db.dump).
Is there any point to archiving a single file, or is .tar.gz just such a…

gardenhead
- 2,017
105
votes
3 answers
Why can't a normal user `chown` a file?
Why is the chown command root-only?
Why can't non-root users use chown to give away files they own?

phleg
- 1,051
105
votes
12 answers
How can I turn off "middle mouse button paste" functionality in all programs?
I don't like having the middle mouse button paste, because I often end up with uncompilable code in Eclipse. How can I turn this off (in all programs)? I'm running Fedora.

derekhh
- 1,227
105
votes
10 answers
How to mount a device in Linux?
I read some resources about the mount command for mounting devices on Linux, but none of them is clear enough (at least for me).
On the whole this what most guides state:
$ mount
(lists all currently mounted devices)
$…

its_me
- 13,959
105
votes
9 answers
When would you use an additional file descriptor?
I know you can create a file descriptor and redirect output to it. e.g.
exec 3<> /tmp/foo # open fd 3.
echo a >&3 # write to it
exec 3>&- # close fd 3.
But you can do the same thing without the file descriptor:
FILE=/tmp/foo
echo a > "$FILE"
I'm…

dogbane
- 29,677
105
votes
4 answers
Why is `while IFS= read` used so often, instead of `IFS=; while read..`?
It seems that normal practice would put the setting of IFS outside the while loop in order to not repeat setting it for each iteration... Is this just a habitual "monkey see, monkey do" style, as it has been for this monkey until I read man read, or…

Peter.O
- 32,916
105
votes
3 answers
sudo as another user with their environment
$ whoami
admin
$ sudo -S -u otheruser whoami
otheruser
$ sudo -S -u otheruser /bin/bash -l -c 'echo $HOME'
/home/admin
Why isn't $HOME being set to /home/otheruser even though bash is invoked as a login shell?
Specifically,…

user80551
- 1,619
- 4
- 16
- 21
105
votes
7 answers
List ports a process PID is listening on (preferably using iproute2 tools)?
I'm looking to list all ports a PID is currently listening on.
How would you recommend I get this kind of data about a process?

ThorSummoner
- 4,422
105
votes
3 answers
What's the purpose of the randomart image for user (not host) SSH keys?
The ssh-keygen generates the following output:
The key fingerprint is:
dd:e7:25:b3:e2:5b:d9:f0:25:28:9d:50:a2:c9:44:97 user@machine
The key's randomart image is:
+--[ RSA 2048]----+
| .o o.. |
| o +Eo |
| + . |
| …

syntagma
- 12,311
105
votes
4 answers
The ls command is not working for a directory with a huge number of files
I had a directory which had around 5 million files. When I tried to run the ls command from inside this directory, my system consumed a huge amount of memory and it hung after sometime. Is there an efficient way to list the files other than using…

Ramesh
- 39,297
104
votes
6 answers
How can I create a /dev/null-like "blackhole" directory?
I would like to create a "/dev/null" directory (or a "blackhole" directory) such that any files written to it are not really written, but just disappear.
I have an application that writes out large temporary files to a directory. I have no control…

dogbane
- 29,677