All Questions

Filter by
Sorted by
Tagged with
1815 votes
3 answers
421k 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 ...
user avatar
1492 votes
10 answers
447k 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?
user avatar
  • 33k
1429 votes
16 answers
3.0m 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 ...
user avatar
1239 votes
12 answers
3.0m 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 ...
user avatar
  • 15.6k
1094 votes
10 answers
3.9m views

How to copy files from one machine to another using ssh

I'm using Linux (centos) machine, I already connected to the other system using ssh. Now my question is how can I copy files from one system to another system? Suppose, in my environment, I have two ...
user avatar
  • 14.4k
1043 votes
9 answers
3.1m 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?
user avatar
  • 89.9k
913 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 ...
user avatar
  • 215k
890 votes
3 answers
514k 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 "...
user avatar
842 votes
2 answers
173k views

Why was '~' chosen to represent the home directory?

I have often wondered why the ~ (tilde) represents the home directory of a user. Is there a reason behind this, or is it just some infrequently used character?
user avatar
786 votes
6 answers
1.2m 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,...
user avatar
  • 8,179
777 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 ...
user avatar
  • 9,032
749 votes
2 answers
1.7m 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?
user avatar
743 votes
3 answers
381k 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?
user avatar
  • 13.4k
726 votes
6 answers
1.2m views

How to run find -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?
user avatar
  • 28.8k
725 votes
4 answers
353k views

Difference between nohup, disown and &

What are the differences between $ nohup foo and $ foo & and $ foo & $ disown
user avatar
  • 25.2k
717 votes
40 answers
795k 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
709 votes
5 answers
282k views

What does "--" (double-dash) 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?
user avatar
  • 26.9k
704 votes
4 answers
461k views

How to cycle through reverse-i-search in BASH?

In the terminal, I can type Ctrl + R to search for a matching command previously typed in BASH. E.g., if I type Ctrl + R then grep, it lists my last grep command, and I can hit enter to use it. This ...
user avatar
  • 5,345
674 votes
10 answers
2.8m 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?
user avatar
  • 60.7k
673 votes
8 answers
186k 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 ...
user avatar
  • 6,857
664 votes
24 answers
244k 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 ...
user avatar
  • 14.9k
662 votes
12 answers
730k 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 ...
user avatar
  • 14.5k
655 votes
4 answers
287k 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 ...
user avatar
  • 11.6k
654 votes
9 answers
2.3m views

How do I zip/unzip on the unix command line?

How can I create and extract zip archives from the command line?
user avatar
  • 7,317
653 votes
5 answers
1.8m 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.
user avatar
  • 9,607
650 votes
29 answers
1.1m 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....
user avatar
  • 7,065
622 votes
5 answers
183k 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 ...
user avatar
  • 33k
617 votes
3 answers
466k 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 ...
user avatar
616 votes
10 answers
266k 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....
user avatar
  • 6,521
598 votes
19 answers
794k 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 ...
user avatar
  • 24.2k
593 votes
25 answers
631k 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 ...
user avatar
  • 6,079
593 votes
4 answers
872k 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 ...
user avatar
  • 41.3k
591 votes
6 answers
1.2m 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 ...
user avatar
  • 6,347
585 votes
9 answers
615k 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 ...
user avatar
  • 36.2k
575 votes
14 answers
689k 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.
user avatar
  • 60.7k
572 votes
8 answers
413k 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 installing software ...
user avatar
  • 6,062
546 votes
27 answers
789k 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.
user avatar
544 votes
7 answers
472k 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 ...
user avatar
  • 5,973
530 votes
9 answers
834k 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?
user avatar
524 votes
10 answers
1.1m 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 ...
user avatar
  • 5,675
521 votes
10 answers
194k 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.
user avatar
  • 28.8k
513 votes
7 answers
764k 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
512 votes
7 answers
1.3m views

Can I zip an entire folder using gzip?

I'm trying to zip a folder in unix. Can that be done using the gzip command?
user avatar
  • 5,221
512 votes
10 answers
913k 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 ...
user avatar
512 votes
3 answers
420k 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.
user avatar
491 votes
14 answers
282k views

Turn off buffering in pipe

I have a script which calls two commands: long_running_command | print_progress The long_running_command prints progress but I'm unhappy with it. I'm using print_progress to make it nicer (namely, I ...
user avatar
491 votes
8 answers
547k 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 ...
user avatar
  • 16.8k
488 votes
4 answers
530k 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
486 votes
12 answers
1.3m views

How to forward X over SSH to run graphics applications remotely?

I have a machine running Ubuntu which I SSH to from my Fedora 14 machine. I want to forward X from the Ubuntu machine back to Fedora so I can run graphical programs remotely. Both machines are on a ...
user avatar
486 votes
7 answers
272k views

Difference between Login Shell and Non-Login Shell?

I understand the basic difference between an interactive shell and a non-interactive shell. But what exactly differentiates a login shell from a non-login shell? Can you give examples for uses of a ...
user avatar
  • 6,499

15 30 50 per page
1
2 3 4 5
4355