All Questions

Filter by
Sorted by
Tagged with
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 ...
Jaroslav Kucera's user avatar
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 ...
Abdul Al Hazred's user avatar
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?
Lazer's user avatar
  • 35.6k
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 ...
Paolo's user avatar
  • 17.6k
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, ...
user3021349's user avatar
  • 16.8k
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?
Tim's user avatar
  • 104k
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,...
10robinho's user avatar
  • 10.6k
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 ...
terdon's user avatar
  • 245k
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 "...
imz -- Ivan Zakharyaschev's user avatar
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 ...
xralf's user avatar
  • 15.3k
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?
Paul Sheldrake's user avatar
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?
Lelouch Lamperouge's user avatar
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 ...
Village's user avatar
  • 3,797
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?
dogbane's user avatar
  • 30.1k
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 ...
user avatar
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 ...
Dan's user avatar
  • 9,572
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?
Wesley's user avatar
  • 14.4k
790 votes
6 answers
415k views

Difference between nohup, disown and &

What are the differences between $ nohup foo and $ foo & and $ foo & $ disown
Lesmana's user avatar
  • 27.7k
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?
ripper234's user avatar
  • 32.1k
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 ...
wuchang's user avatar
  • 8,227
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.
tkbx's user avatar
  • 11.1k
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 ...
Wilduck's user avatar
  • 7,657
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?
tshepang's user avatar
  • 66.5k
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....
Thom's user avatar
  • 7,925
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 ...
mtk's user avatar
  • 27.9k
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 ...
amphibient's user avatar
  • 12.6k
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 ...
Oli's user avatar
  • 16.2k
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 ...
Lazer's user avatar
  • 35.6k
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 ...
LanceBaynes's user avatar
  • 40.7k
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?
joachim's user avatar
  • 7,767
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....
TheGeeko61's user avatar
  • 7,091
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 ...
Justin Garrison's user avatar
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 ...
dreeves's user avatar
  • 6,689
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 ...
TheLegend's user avatar
  • 6,935
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 ...
Patches's user avatar
  • 6,752
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.
tshepang's user avatar
  • 66.5k
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 ...
landroni's user avatar
  • 11.2k
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 ...
Łukasz Zaroda's user avatar
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 ...
cwd's user avatar
  • 45.9k
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.
Eugene Yarmash's user avatar
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?
Theodor Coogan's user avatar
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.
ripper234's user avatar
  • 32.1k
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 ...
AeroCross's user avatar
  • 6,433
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.
Gilles 'SO- stop being evil''s user avatar
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 ...
Cory Klein's user avatar
  • 19.1k
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?
user avatar
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 ...
Andrew's user avatar
  • 17.2k
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 ...
Psachnodaimonia's user avatar
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 ...
RetroCode's user avatar
  • 5,899
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 ...
user avatar

15 30 50 per page
1
2 3 4 5
4825