All Questions
241,248
questions
1862
votes
3
answers
444k
views
Why does man print "gimme gimme gimme" at 00:30?
We've noticed that some of our automatic tests fail when they run at 00:30 but work fine the rest of the day. They fail with the message
gimme gimme gimme
in stderr, which wasn't expected. Why are we ...
1650
votes
16
answers
3.6m
views
How do I get the size of a directory on the command line?
I tried to obtain the size of a directory (containing directories and sub directories) by using the ls command with option l. It seems to work for files (ls -l file name), but if I try to get the size ...
1612
votes
10
answers
529k
views
What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?
I think these terms almost refer to the same thing, when used loosely:
terminal
shell
tty
console
What exactly does each of these terms refer to?
1389
votes
12
answers
3.5m
views
How to correctly add a path to PATH?
I'm wondering where a new path has to be added to the PATH environment variable. I know this can be accomplished by editing .bashrc (for example), but it's not clear how to do this.
This way:
export ...
1294
votes
13
answers
5.0m
views
How to copy files from one machine to another using ssh
I am using a Linux (CentOS) machine, and I have already connected to another system using SSH.
Now, my question is: How can I copy files from one system to another system?
Suppose, in my environment, ...
1206
votes
9
answers
3.7m
views
How to install a deb file, by dpkg -i or by apt?
I have a deb package for installation.
Shall I install by dpkg -i my.deb, or by apt?
Will both handle the software dependency problem well?
If by apt, how can I install from the deb by apt?
1027
votes
6
answers
1.9m
views
How to see full log from systemctl status service?
I check service status with systemctl status service-name.
By default, I see few rows only, so I add -n50 to see more.
Sometimes, I want to see full log, from start. It could have 1000s of rows.
Now,...
967
votes
10
answers
1.8m
views
How can I replace a string in a file(s)?
Replacing strings in files based on certain search criteria is a very common task. How can I
replace string foo with bar in all files in the current directory?
do the same recursively for sub ...
958
votes
3
answers
573k
views
How to unfreeze after accidentally pressing Ctrl-S in a terminal?
It's a situation that has happened quite often to me: after I press (with a different intention) Ctrl-S in a terminal, the interaction (input or output) with it is frozen. It's probably a kind of "...
911
votes
15
answers
1.1m
views
How can I reduce a video's size with ffmpeg?
How can I use ffmpeg to reduce the size of a video by lowering the quality (as minimally as possible, naturally, because I need it to run on a mobile device that doesn't have much available space)?
I ...
906
votes
2
answers
2.3m
views
How do I make `ls` show file sizes in megabytes?
What commands do I need for Linux's ls to show the file size in MB?
862
votes
2
answers
179k
views
Why was '~' chosen to represent the home directory?
I have often wondered why the ~ (tilde) character represents the home directory of a user.
Is there a reason behind this, or is it just because tilde is an infrequently used character?
832
votes
4
answers
611k
views
How to cycle through reverse-i-search in Bash?
In the GNU bash shell, I can type Ctrl + R to search for a matching command previously run. E.g., if I type Ctrl + R and then "grep", it lists my last grep command, and I can hit Enter to ...
830
votes
5
answers
370k
views
What does "--" (double dash / double hyphen) mean?
I have seen -- used in the compgen command.
For example:
compgen -W "foo bar baz" -- b
What is the meaning of the -- in there?
816
votes
40
answers
975k
views
Tracking down where disk space has gone on Linux?
When administering Linux systems I often find myself struggling to track down the culprit after a partition goes full. I normally use du / | sort -nr but on a large filesystem this takes a long time ...
808
votes
13
answers
1.8m
views
How do I grep for multiple patterns with pattern having a pipe character?
I want to find all lines in several files that match one of two patterns. I tried to find the patterns I'm looking for by typing
grep (foo|bar) *.txt
but the shell interprets the | as a pipe and ...
795
votes
3
answers
448k
views
What is the purpose of the lost+found folder in Linux and Unix?
There is a folder at the root of Linux and Unix operating systems called /lost+found/
What is it for? Under what circumstances would I interact with it? How would I interact with it?
790
votes
6
answers
415k
views
Difference between nohup, disown and &
What are the differences between
$ nohup foo
and
$ foo &
and
$ foo &
$ disown
787
votes
6
answers
1.3m
views
Problem running find: missing argument to `-exec'
I'd like to find the files in the current directory that contain the text "chrome".
$ find . -exec grep chrome
find: missing argument to `-exec'
What am I doing wrong?
777
votes
8
answers
1.9m
views
Finding the PID of the process using a specific port?
I am installing hadoop on my Ubuntu system. When I start it, it reports that port 9000 is busy.
I used:
netstat -nlp|grep 9000
to see if such a port exists and I got this:
tcp 0 0 ...
776
votes
6
answers
2.1m
views
Zip all files in directory?
Is there a way to zip all files in a given directory with the zip command? I've heard of using *.*, but I want it to work for extensionless files, too.
753
votes
9
answers
222k
views
What do the numbers in a man page mean?
So, for example, when I type man ls I see LS(1). But if I type man apachectl I see APACHECTL(8) and if I type man cd I end up with cd(n).
I'm wondering what the significance of the numbers in the ...
748
votes
11
answers
3.2m
views
How to switch between users on one terminal?
I'd like to log in as a different user without logging out of the current one (on the same terminal). How do I do that?
736
votes
30
answers
1.3m
views
Why am I still getting a password prompt with ssh with public key authentication?
I'm working from the URL I found here:
http://web.archive.org/web/20160404025901/http://jaybyjayfresh.com/2009/02/04/logging-in-without-a-password-certificates-ssh/
My ssh client is Ubuntu 64 bit 11....
728
votes
21
answers
1.0m
views
How to get execution time of a script effectively?
I would like to display the completion time of a script.
What I currently do is -
#!/bin/bash
date ## echo the date at start
# the script contents
date ## echo the date at end
This just show's ...
718
votes
4
answers
318k
views
Why is printf better than echo?
I have heard that printf is better than echo. I can recall only one instance from my experience where I had to use printf because echo didn't work for feeding some text into some program on RHEL 5.8 ...
717
votes
24
answers
283k
views
Preserve bash history in multiple terminal windows
I consistently have more than one terminal open. Anywhere from two to ten, doing various bits and bobs. Now let's say I restart and open up another set of terminals. Some remember certain things, some ...
696
votes
5
answers
235k
views
/usr/bin vs /usr/local/bin on Linux
Why are there so many places to put a binary in Linux? There are at least these five:
/bin/
/sbin/
/usr/bin/
/usr/local/bin/
/usr/local/sbin/
And on my office box, I do not have write permissions to ...
685
votes
12
answers
851k
views
How to force ssh client to use only password auth?
If I use pubkey auth from e.g.: an Ubuntu 11.04 how can I set the ssh client to use only password auth to a server? (just needed because of testing passwords on a server, where I default log in with ...
682
votes
9
answers
2.4m
views
How do I zip/unzip on the unix command line?
How can I create and extract zip archives from the command line?
671
votes
11
answers
297k
views
Why is it better to use "#!/usr/bin/env NAME" instead of "#!/path/to/NAME" as my shebang?
I notice that some scripts which I have acquired from others have the shebang #!/path/to/NAME while others (using the same tool, NAME) have the shebang #!/usr/bin/env NAME.
Both seem to work properly....
657
votes
4
answers
502k
views
Using "${a:-b}" for variable assignment in scripts
I have been looking at a few scripts other people wrote (specifically Red Hat), and a lot of their variables are assigned using the following notation
VARIABLE1="${VARIABLE1:-some_val}"
or some expand ...
654
votes
24
answers
729k
views
Repeat a Unix command every x seconds forever
There's a built-in Unix command repeat whose first argument is the number of times to repeat a command, where the command (with any arguments) is specified by the remaining arguments to repeat.
For ...
649
votes
11
answers
1.4m
views
How to append multiple lines to a file
I am writing a bash script to look for a file if it doesn't exist then create it and append this to it:
Host localhost
ForwardAgent yes
So "line then new line 'tab' then text" I think its a ...
641
votes
8
answers
477k
views
What is the difference between /opt and /usr/local?
According to the Filesystem Hierarchy Standard, /opt is for "the installation of add-on application software packages". /usr/local is "for use by the system administrator when ...
637
votes
16
answers
795k
views
What if 'kill -9' does not work?
I have a process I can't kill with kill -9 <pid>. What's the problem in such a case, especially since I am the owner of that process. I thought nothing could evade that kill option.
632
votes
26
answers
682k
views
How to generate a random string?
I would like to generate a random string (e.g. passwords, user names, etc.). It should be possible to specify the needed length (e.g. 13 chars).
What tools can I use?
(For security and privacy ...
630
votes
16
answers
928k
views
How to clear journalctl
I couldn't find in google any safe way to clear systemd journal. Do anyone know any safe and reliable way to do so?
Let's say I was experimenting with something and my logs got cluttered with various ...
619
votes
4
answers
953k
views
Does curl have a --no-check-certificate option like wget?
I am trying to make a curl request to one of our local development servers running a dev site with a self-signed SSL cert. I am using curl from the command line.
I saw some blog posts mentioning that ...
613
votes
28
answers
935k
views
How can I resolve a hostname to an IP address in a Bash script?
What's the most concise way to resolve a hostname to an IP address in a Bash script? I'm using Arch Linux.
591
votes
10
answers
1.0m
views
How to display `top` results sorted by memory usage in real time?
How can I display the top results in my terminal in real time so that the list is sorted by memory usage?
589
votes
11
answers
243k
views
Can less retain colored output?
Can I get less not to monochrome its output?
E.g., the output from git diff is colored, but git diff | less is not.
588
votes
7
answers
539k
views
Scroll inside Screen, or Pause Output
I use screen for my command-line tasks while managing the servers where I work. I usually run small commands (mostly file-system tasks) but sometimes I run more extensive tasks (like DBA).
The output ...
586
votes
3
answers
511k
views
What is a bind mount?
What is a “bind mount”? How do I make one? What is it good for?
I've been told to use a bind mount for something, but I don't understand what it is or how to use it.
585
votes
9
answers
702k
views
Can grep output only specified groupings that match?
Say I have a file:
# file: 'test.txt'
foobar bash 1
bash
foobar happy
foobar
I only want to know what words appear after "foobar", so I can use this regex:
"foobar \(\w\+\)"
The parenthesis ...
582
votes
8
answers
964k
views
How do I check package version using apt-get / aptitude?
Before I install a package, I'd like to know what version I would get.
How do I check the version before installing using apt-get or aptitude on Debian or Ubuntu?
580
votes
4
answers
1.7m
views
In a bash script, using the conditional "or" in an "if" statement
This question is a sequel of sorts to my earlier question. The users on this site kindly helped me determine how to write a bash for loop that iterates over string values. For example, suppose that ...
575
votes
12
answers
1.1m
views
How do I copy a folder keeping owners and permissions intact?
So I was going to back up my home folder by copying it to an external drive as follows:
sudo cp -r /home/my_home /media/backup/my_home
With the result that all folders on the external drives are now ...
575
votes
7
answers
298k
views
What is the difference between the Bash operators [[ vs [ vs ( vs ((?
I am a little bit confused on what do these operators do differently when used in bash (brackets, double brackets, parenthesis and double parenthesis).
[[ , [ , ( , ((
I have seen people use them on ...
572
votes
4
answers
700k
views
recursive mkdir
Is there a linux command that I'm overlooking that makes it possible to do something along the lines of:
(pseudo)
$ mkdir -R foo/bar/zoo/andsoforth
Or is there no alternative but to make the ...