Most Popular
1500 questions
121
votes
7 answers
rsync compare directories?
Is it possible to compare two directories with rsync and only print the differences? There's a dry-run option, but when I increase verbosity to a certain level, every file compared is shown.
ls -alR and diff is no option here, since there are…

chris
- 1,685
121
votes
5 answers
What process created this X11 window?
Given an X11 window ID, is there a way to find the ID of the process that created it?
Of course this isn't always possible, for example if the window came over a TCP connection. For that case I'd like the IP and port associated with the remote…

Gilles 'SO- stop being evil'
- 829,060
121
votes
12 answers
Kill many instances of a running process with one command
Suppose I have a thousand or more instances of any process (for example, vi) running. How do I kill them all in one single shot/one line command/one command?

The Dark Knight
- 2,254
121
votes
16 answers
How to determine the path to a sourced tcsh or bash shell script from within the script
Is there a way for a sourced shell script to find the path to itself? I'm mainly concerned with bash, though I have some coworkers who use tcsh.
I'm guessing I may not have much luck here since sourcing causes commands to be executed in the current…

Cascabel
- 1,651
121
votes
5 answers
How to see the latest x lines from systemctl service log
I'm looking for a way, to simply print the last X lines from a systemctl service in Debian. I would like to install this code into a script, which uses the printed and latest log entries. I've found this post but I wasn't able to modify it for my…

user3191334
- 1,479
121
votes
2 answers
ulimit: difference between hard and soft limits
What is the difference between hard and soft limits in ulimit?
For number of open files, I have a soft limit of 1024 and a hard limit of 10240.
It is possible to run programs opening more than 1024 files. What is the soft limit for?

daniel kullmann
- 9,527
- 11
- 39
- 46
121
votes
7 answers
Can I safely remove /var/cache?
I am running out of disk space and noted that I have a large /var/cache directory. Can I safely remove this? (using Arch Linux, BTW).
user11780
121
votes
12 answers
How do I check if a variable exists in an 'if' statement?
I need to check a variable's existence in an if statement. Something to the effect of:
if [ -v $somevar ]
then
echo "Variable somevar exists!"
else
echo "Variable somevar does not exist!"
And the closest question to that was this, which…
user104976
121
votes
3 answers
How do I write all lines from less to a file?
I've piped a command to less, and now I want to save the command's output to a file. How do I do that?
In this case, I don't want to use tee, I want a solution directly from less, so that I don't have to rerun a long-running command if I forgot to…

Flimm
- 4,218
120
votes
6 answers
What is the difference between Halt and Shutdown commands?
What is the difference between the halt and shutdown commands?

wassimans
- 1,521
120
votes
5 answers
Command-line completion from command history
So, I've looked at history and at Ctrl+R, but they are not what I thought I knew.
Is there a way that I can type in the beginning of a command, and cycle through the matches in my history with some bash shortcut?
# mysq(some shortcut key)
Gives…

Ben Dauphinee
- 1,303
120
votes
6 answers
How to do an if statement from the result of an executed command
I am trying to do an IF statement from the output of an executed commmand. Here is how I am trying to do it, but it doesn't work. Does anyone know the right way to do this?
if [ "`netstat -lnp | grep ':8080'`" == *java* ]; then
echo "Found a…

djangofan
- 4,147
120
votes
13 answers
How to create SHA512 password hashes on command line
In Linux I can create a SHA1 password hash using sha1pass mypassword. Is there a similar command line tool which lets me create sha512 hashes? Same question for Bcrypt and PBKDF2.

student
- 18,305
120
votes
4 answers
Systemd service - what is `multi-user.target`
I have come across a .service that contains the following:
[Install]
WantedBy=multi-user.target
The original .service file can be found here.
What is the the meaning of multi-user.target?
I am on Ubuntu 16.04 LTS.

eddyP23
- 1,311
120
votes
1 answer
What happens when you 'mount over' an existing folder with contents?
Right now /tmp has some temporary files in it. When I mount my hard drive (/dev/sdc1) on top of /tmp, I can see the files on the hard drive. What happens to the actual content of /tmp when my hard drive is mounted? Is it possible to perform r/w…

user
- 1,589