Most Popular
1500 questions
104
votes
11 answers
How do I echo just 1 column of output from ls command?
Lets say when I do ls command the output is:
file1 file2 file3 file4
Is it possible to display only a certain column of output, in this case file2? I have tried the following with no success:
echo ls | $2
Basically all I want to do is echo only…

John
- 3,599
103
votes
2 answers
Make xargs pass as first parameter
I'm trying to produce this behaviour:
grep 192.168.1 *.txt
By passing a string into grep via Xargs but it is going on the end instead of as the first parameter.
echo 192.168.1 | xargs grep *.txt
I need to tell xargs (or something similar) to put…

andy boot
- 1,193
103
votes
8 answers
Creating a ram disk on Linux
I have a machine with 62GB of RAM, and a trunk that's only 7GB, so I thought I would create a RAM disk and compile there. I am not a Linux expert. I found instructions on the internet to create the RAM disk:
mkfs -q /dev/ram1 8192
but I changed…

Frank
- 1,031
103
votes
5 answers
What is the point of sshd “UseDNS” option?
I know what it does, but I don't know why. What attack(s) does it prevent?
Is it relevant for all kind of authentication methods? (hostbased, password, publickey, keyboard-interactive ...)

user368507
- 2,173
103
votes
2 answers
How do I copy a symbolic link?
I have a symbolic link to a file in one directory. I would like to have that same link in another directory. How do I copy a symbolic link?
I tried to cp the symbolic link but this copies the file it points to instead of the symbolic link itself.

User
- 2,297
103
votes
4 answers
Replacing only specific variables with envsubst
I'm trying to perform environment variable replacement through envsubst, but I want to only replace specific variables.
From the docs I should be able to tell envsubst to only replace certain variables but I'm failing to be able to do that.
For…

João Angelo
- 1,133
103
votes
8 answers
How do you list number of lines of every file in a directory in human readable format.
I have a list of directories and subdirectories that contain large csv files. There are about 500 million lines in these files, each is a record. I would like to know
How many lines are in each file.
How many lines are in directory.
How many…

Hexatonic
- 1,275
- 3
- 10
- 9
103
votes
3 answers
Rebuild auto-complete index (or whatever it's called) and binaries in $PATH cache in zsh
After installing new software, an already opened terminal with zsh won't know about the new commands and cannot generate auto-complete for those. Apparently opening a new terminal fix the problem, but can the index (or whatever you call it) be…

phunehehe
- 20,240
103
votes
4 answers
Command to list PostgreSQL user accounts?
There are createuser & dropuser commands:
createuser - define a new PostgreSQL user account
dropuser - remove a PostgreSQL user account
Is there a corresponding way to list the user accounts?
These two commands do not require the user to invoke…

CW Holeman II
- 3,684
103
votes
5 answers
How to find out if a system uses SysV, Upstart or Systemd initsystem
Is there a simple way to find out which initsystem is being used e.g by a recent Debian wheezy or Fedora system? I'm aware that Fedora 21 uses systemd initsystem but that is because I read that and because all relevant scripts/symlinks are stored…

Valentin Bajrami
- 9,344
103
votes
2 answers
Difference between 'echo' and 'echo -e'
What is the difference between echo and echo -e?
And which quotes ("" or '') should be used with the echo command? i.e: echo "Print statement" or echo 'Print statement'?
Also, what are the available options that can be used along with echo?

Venkatesh
- 1,171
103
votes
8 answers
Does /usr/sbin/nologin as a login shell serve a security purpose?
In my /etc/passwd file, I can see that the www-data user used by Apache, as well as all sorts of system users, have either /usr/sbin/nologin or /bin/false as their login shell. For example, here is a selection of…

Mark Amery
- 3,000
103
votes
5 answers
Recover cron jobs accidently removed with crontab -r
I entered crontab -r instead of crontab -e and all my cron jobs have been removed.
What is the best way (or is there one) to recover those jobs?

Teerath Kumar
- 1,135
102
votes
5 answers
Remove line containing certain string and the following line
I use this
cat foo.txt | sed '/bar/d'
to remove lines containing the string bar in the file.
I would like however to remove those lines and the line directly after it. Preferably in sed, awk or other tool that's available in MinGW32.
It's a kind of…

jakub.g
- 3,263
- 5
- 21
- 18
102
votes
1 answer
Make cd follow symbolic links
I have my code mounted as an sshfs in my home directory, but the hierarchy is difficult to remember, so I created a symlink in my home directory leading to that directory. Is there a way so that when I cd to that symbolic link, instead of cding to…

rowantran
- 1,865