Most Popular
1500 questions
128
votes
7 answers
How are "/dev" Linux files created?
There are special files in Linux that are not really files.
The most notable and clear examples of these are in the dev folder, "files" like:
/dev/null - Ignores anything you write to the file
/dev/random - Outputs random data instead of the…

IQAndreas
- 10,345
128
votes
5 answers
Exclude one pattern from glob match
I have several files with the same base filename. I'd like to remove all but one
foo.org #keep
foo.tex #delete
foo.fls #delete
foo.bib #delete
etc
If I didn't need to keep one, I know I could use rm foo.*.
TLDP demonstrates ^ to negate a match.…

jake
- 1,487
128
votes
6 answers
Why is setting a variable before a command legal in bash?
I've just encountered several answers such as to parsing a delimited text file... that use the construct:
while IFS=, read xx yy zz;do
echo $xx $yy $zz
done < input_file
where the IFS variable is set before the read command.
I've been reading…

Mike Lippert
- 1,385
127
votes
20 answers
gpg asks for password even with --passphrase
I expect the following command to extract the gpg file without asking for password:
gpg --passphrase 1234 file.gpg
But it asks for the password. Why?
This also have the same behavior:
gpg --passphrase-file passfile.txt file.gpg
I use Ubuntu…

Omid
- 3,391
127
votes
5 answers
Unable to locate package `docker-ce` on a 64bit ubuntu
I'm trying to install Docker on a Ubuntu 64 machine following the official installation guide.
Sadly Ubuntu seems it is not able to locate the docker-ce package. Any idea to fix it or at least to track what is happening ?
Here some details for…

danidemi
- 1,553
127
votes
3 answers
su vs sudo -s vs sudo -i vs sudo bash
What is the difference between the following commands:
su
sudo -s
sudo -i
sudo bash
I know for su I need to know the root password, and for sudo I have to be in the sudoers file, but once executed what is difference?
I know there is a difference…

TJ Shah
- 1,761
- 3
- 13
- 13
127
votes
11 answers
How can I install the `ll` command on Mac OS X?
I'm using Mac OS X. When I SSH into servers I find the ll command useful, but it's not available on my local machine. How can I install it?

Eonil
- 4,657
127
votes
6 answers
Process substitution and pipe
I was wondering how to understand the following:
Piping the stdout of a command into the stdin of another is a powerful
technique. But, what if you need to pipe the stdout of multiple
commands? This is where process substitution comes in.
In…

Tim
- 101,790
127
votes
3 answers
How can I assign the output of a command to a shell variable?
I want to assign the result of an expression
(i.e., the output from a command)
to a variable and then manipulate it – for example,
concatenate it with a string, then echo it.
Here's what I've got:
#!/bin/bash
cd ~/Desktop;
thefile= ls -t -U | grep…

Nathan G.
- 1,418
127
votes
6 answers
What is the difference between 'env' and 'printenv'?
What is the difference between the two commands env and printenv? They both show the environment variables, and the output is exactly the same aside from _.
Are there any historical reasons for there being two commands instead of one?

WiSaGaN
- 1,433
127
votes
3 answers
^x^y unix trick for all instances in last command?
One of my favorite Unix tricks is ^x^y, which will take the last command and replace the first instance of "x" with "y". However, I'm wondering if a similar trick works to replace all instances of "x" with "y" in the last command?

Mason
- 1,413
- 2
- 10
- 6
126
votes
6 answers
Why is the Linux kernel 15+ million lines of code?
What are the contents of this monolithic code base?
I understand processor architecture support, security, and virtualization, but I can't imagine that being more than 600,000 lines or so.
What are the historic & current reason drivers are included…

Jonathan
- 1,565
126
votes
9 answers
How to add newlines into variables in bash script
When I do
str="Hello World\n===========\n"
I get the \n printed out too. How can I have newlines then?

Jiew Meng
- 2,433
126
votes
8 answers
Disable a user's login without disabling the account
Let's say I create a user named "bogus" using the adduser command. How can I make sure this user will NOT be a viable login option, without disabling the account. In short, I want the account to be accessible via su - bogus, but I do not want it to…

Malabarba
- 2,059
126
votes
11 answers
Is there any option with 'ls' command that I see only the directories?
Sometimes, I need to check only the directories not files. Is there any option with the command ls? Or is there any utility for doing that?
EDIT: I'm using Mac OS X, and ls -d gives me . even though I have directories.

prosseek
- 8,558