All Questions

Filter by
Sorted by
Tagged with
1860 votes
3 answers
439k 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
1621 votes
16 answers
3.5m 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
1591 votes
10 answers
518k 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.2k
1358 votes
12 answers
3.4m 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.3k
1260 votes
13 answers
4.8m 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.4k
1183 votes
9 answers
3.6m 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
  • 101k
977 votes
6 answers
1.8m 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.1k
958 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
  • 241k
951 votes
3 answers
558k 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
882 votes
2 answers
2.2m 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
875 votes
13 answers
1.0m 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.7k
861 votes
2 answers
178k 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
810 votes
4 answers
573k 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 ...
Village's user avatar
  • 4,945
805 votes
5 answers
354k 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?
dogbane's user avatar
  • 29.6k
802 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,482
798 votes
40 answers
929k 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
784 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
  • 31.6k
783 votes
3 answers
429k 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.2k
782 votes
6 answers
403k views

Difference between nohup, disown and &

What are the differences between $ nohup foo and $ foo & and $ foo & $ disown
Lesmana's user avatar
  • 27.4k
745 votes
5 answers
2.0m 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
  • 10.8k
741 votes
9 answers
215k 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,537
735 votes
10 answers
3.1m 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
  • 65.4k
734 votes
8 answers
1.7m 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
  • 7,787
728 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,845
710 votes
20 answers
984k 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.4k
709 votes
24 answers
276k 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
  • 16k
706 votes
4 answers
312k 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.4k
687 votes
5 answers
224k 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.2k
676 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?
joachim's user avatar
  • 7,677
674 votes
12 answers
805k 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
664 votes
10 answers
290k 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,021
653 votes
4 answers
498k 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
645 votes
24 answers
717k 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,599
635 votes
11 answers
1.3m 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,795
628 votes
8 answers
465k 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,622
622 votes
15 answers
772k 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
  • 65.4k
616 votes
4 answers
932k 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.2k
603 votes
27 answers
900k 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
601 votes
26 answers
613k 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
  • 10.8k
594 votes
16 answers
825k 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
583 votes
7 answers
524k 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,373
581 votes
11 answers
236k 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
  • 31.6k
580 votes
10 answers
952k 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
578 votes
8 answers
679k 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
  • 18.9k
575 votes
3 answers
491k 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
571 votes
7 answers
914k 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
558 votes
4 answers
668k 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
557 votes
4 answers
1.6m 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
  • 16.8k
556 votes
8 answers
320k 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 ...
Igorio's user avatar
  • 7,479
555 votes
12 answers
1.0m 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

15 30 50 per page
1
2 3 4 5
4751