Most Popular
1500 questions
196
votes
6 answers
how can I add (subtract, etc.) two numbers with bash?
I can read the numbers and operation in with:
echo "First number please"
read num1
echo "Second number please"
read num2
echo "Operation?"
read op
but then all my attempts to add the numbers fail:
case "$op" in
"+")
echo num1+num2;;
"-")
…

Michael Durrant
- 42,013
196
votes
12 answers
What are the pros/cons of deb vs. rpm?
For whatever reasons, I've always used RPM based distributions (Fedora, Centos and currently openSUSE). I have often heard it stated that deb is better than rpm, but when asked why, have never been able to get a coherent answer (usually get some…

Evan
- 2,111
196
votes
3 answers
How to list disks, partitions and filesystems in Linux?
In Windows, if you type LIST DISK using DiskPart in a command prompt it lists all physical storage devices, plus their size, format, etc. What is the equivalent of this in Linux?

Mia
- 1,971
196
votes
7 answers
Temporarily suspend bash_history on a given shell?
Is there a way to temporarily suspend history tracking in bash, so as to enter a sort of "incognito" mode? I'm entering stuff into my terminal that I don't want recorded, sensitive financial info.

Naftuli Kay
- 39,676
195
votes
12 answers
Is there a way to dynamically refresh the less command?
I like the watch command, but it has its limitations.
I'm curious to know whether I could mimic the functionality of watch with less. I'm mainly looking for the ability to scroll through my directory as it dynamically gets modified via a running…

Zaid
- 10,642
194
votes
12 answers
How to find out from the logs what caused system shutdown?
E.g. I'm seeing this in /var/log/messages:
Mar 01 23:12:34 hostname shutdown: shutting down for system halt
Is there a way to find out what caused the shutdown? E.g. was it run from console, or someone hit power button, etc.?

alex
- 7,223
194
votes
4 answers
Is your SSH password revealed when you attempt to connect to the wrong server?
When you accidentally attempt to connect to the wrong server with password credentials is it possible for the administrator to read and log the password you used?

vfclists
- 7,531
- 14
- 53
- 79
194
votes
4 answers
What is the difference between /tmp and /var/tmp?
On most FHS systems, there is a /tmp folder as well as a /var/tmp folder. What is the functional difference between the two?

Wesley
- 14,263
194
votes
10 answers
How do I use cut to separate by multiple whitespace?
I have this input, which is displayed in columns. I would like to get the second last column with the numbers of this sample:
[ 3] 1.0- 2.0 sec 1.00 MBytes 8.39 Mbits/sec
[ 3] 2.0- 3.0 sec 768 KBytes 6.29 Mbits/sec
[ 3] 3.0- 4.0 sec 512…

rubo77
- 28,966
193
votes
8 answers
cat line X to line Y on a huge file
Say I have a huge text file (>2GB) and I just want to cat the lines X to Y (e.g. 57890000 to 57890010).
From what I understand I can do this by piping head into tail or viceversa, i.e.
head -A /path/to/file | tail -B
or alternatively
tail -C…

Amelio Vazquez-Reina
- 41,161
193
votes
9 answers
How can I disown a running process and associate it to a new screen shell?
I have a running program on a SSH shell. I want to pause it and be able to unpause its execution when I come back.
One way I thought of doing that was to transfer its ownership to a screen shell, thus keeping it running in there.
Is there a…

levesque
- 3,815
193
votes
7 answers
Creating diagrams in ASCII
I am looking for a program which I can use to create ASCII diagrams such these:
+---------+
| | +--------------+
| NFS |--+ | |
| | | +-->| …

Martin Vegter
- 358
- 75
- 236
- 411
192
votes
14 answers
Recover deleted files on Linux
Is there a command to recover/undelete deleted files by rm?
rm -rf /path/to/myfile
How can I recover myfile? If there is a tool to do this, how can I use it?

pylover
- 3,418
192
votes
6 answers
How to uppercase the command line argument?
I searched SO and found that to uppercase a string following would work
str="Some string"
echo ${str^^}
But I tried to do a similar thing on a command-line argument, which gave me the following error
Tried
#!/bin/bash
## Output
echo…

mtk
- 27,530
- 35
- 94
- 130
192
votes
4 answers
How can I check if swap is active from the command line?
How can I check if swap is active, and which swap devices are set up, on the command line?

ptrcao
- 5,635