Most Popular
1500 questions
95
votes
11 answers
How do I use man pages to learn how to use commands?
While researching another problem, I came across a command,
locate something | xargs -I {} bash -c "if [ -d "{}" ]; then echo {}; fi"
that I wanted to learn more about. So I ran man xargs and get the following output:
XARGS(1) …

user1717828
- 3,542
95
votes
8 answers
Using jq to extract values from column-oriented JSON and format in CSV
I have the below JSON file, with the data stored as columns enumerated by rank in an array:
{
"data": [
{
"displayName": "First Name",
"rank": 1,
"value": "VALUE"
},
{
"displayName": "Last Name",
"rank":…

Kerim
- 951
- 1
- 6
- 3
95
votes
6 answers
How to change top's sorting back to CPU?
A former coworker did something to top that whenever it runs as root the data is sorted by MEM usage instead of the default CPU usage. According to multiple searches, the man page and even the options within the top console itself (O), just pressing…
user27807
95
votes
7 answers
How to read first and last line from cat output?
I have text file. Task - get first and last line from file after
$ cat file | grep -E "1|2|3|4" | commandtoprint
$ cat file
1
2
3
4
5
Need this without cat output (only 1 and 5).
~$ cat file | tee >(head -n 1) >(wc -l)
1
2
3
4
5
5
1
Maybe awk…

dmgl
- 1,083
95
votes
8 answers
How to download a folder from google drive using terminal?
I want to download a folder from my google drive using terminal? Is there any way to do that? I tried this:
$ wget "https://drive.google.com/folderview?id=0B-Zc9K0k9q-WWUlqMXAyTG40MjA&usp=sharing"
But it is downloading this text file:…

user22180
- 1,123
95
votes
5 answers
Determine what device a directory is located on
If I do
# cd /
# ln -s /home test
# cd test
# mount --bind $PWD /mnt
the entry in /proc/mounts is
/dev/sda2 /mnt ext4 rw,noatime,data=ordered 0 0
which is the device that is mounted to /home and is not easily deducible from $PWD which is /test.…

StrongBad
- 5,261
95
votes
9 answers
Get list of subdirectories which contain a file whose name contains a string
How can I get a list of the subdirectories which contain a file whose name matches a particular pattern?
More specifically, I am looking for directories which contain a file with the letter 'f' somewhere occurring in the file name.
Ideally, the list…

Muhd
- 1,064
95
votes
3 answers
How to view datetime stamp for history command in Zsh shell
When I run the history command on my ubuntu server, I get output as follows:
history
...
25 cd ~
26 ls -a
27 vim /etc/gitconfig
28 vim ~/.gitconfig
I want to view the datetime of a particular user. However when I assume…

JohnMerlino
- 6,161
94
votes
8 answers
Connect to a Bluetooth device via Terminal
I'm using Mint 15 w/ Cinnamon.
I bought a set of bluetooth speakers and I'm trying to connect to them via terminal. Via the GUI I can see them normally and I am connected to them. I want to make a small script so every time they are visible I would…

Zippie
- 1,879
94
votes
1 answer
Redirect both stderr and stdout to /dev/null with /bin/sh
I have tried all sorts of ways to redirect both stdout and stderr to /dev/null without any success. I have almost my entire life run bash which I've never had this issue with, but for once in BSD I'm stuck with /bin/sh.
What I've tried:
if ls…

Torxed
- 3,637
94
votes
4 answers
Is there any way to keep a command from being added to your history?
Is there any way to keep a command from being added to your history? I have a command that I want to keep out of my history file, and I really don't care to have it there when I search the history stored in memory, though that's less of a concern.…

xenoterracide
- 59,188
- 74
- 187
- 252
94
votes
4 answers
How do I change the default text editor in the Debian (squeeze) distro
"Joe's own editor" does not come naturally to me. How do I change to using nano or vim?
I've tried
export EDITOR=nano
but it doesn't seem to be respected. I'd like visudo to respect this as well.

wmarbut
- 1,041
94
votes
5 answers
How to extract the Root CA and Subordinate CA from a certificate chain in Linux?
I have an end-entity/server certificate which have an intermediate and root certificate. When I cat on the end-entity certificate, I see only a single BEGIN and END tag. It is the only the end-entity certificate.
Is there any way I can view the…

Anirban Nag 'tintinmj'
- 1,145
94
votes
5 answers
Fix or alternative for mktemp in OS X
I'm looking at a bash script someone else wrote that uses mktemp:
TEMP=`mktemp --directory`
However, this line does not work on my machine (OS X 10.6).
How would I fix this line so that it is cross-un*x-like-platform compatible? EDIT: An…

soundly_typed
- 1,043
94
votes
4 answers
How to turn off Wireless power management permanently
In Linux Mint 17.3 / 18 iwconfig says the power management of my wireless card is turned on. I want to turn it off permanently or some workaround on this issue.
sudo iwconfig wlan0 power off works, until I reboot the laptop.
Also, if I randomly…

Vlastimil Burián
- 28,462