Most Popular
1500 questions
150
votes
3 answers
How to check if there are no parameters provided to a command?
How do you check if $* is empty? In other words, how to check if there were no arguments provided to a command?

well actually
- 3,225
- 5
- 22
- 11
150
votes
6 answers
Why does Vim indent pasted code incorrectly?
In Vim, if I paste this script:
#!/bin/sh
VAR=1
while ((VAR < 10))
do
echo "VAR1 is now $VAR"
((VAR = VAR +2))
done
echo "finish"
I get these strange results:
#!/bin/sh
#VAR=1
#while ((VAR < 10))
# do
# …

elbarna
- 12,695
150
votes
13 answers
Show top five CPU consuming processes with `ps`
How to show top five CPU consuming processes with ps?

PlanasB
- 1,645
150
votes
6 answers
How to comment multiple lines at once?
How can I select a bunch of text and comment it all out?
Currently I go to the first line, go to insert mode then type # left-arrowdown-arrow and then I repeat that sequence, perhaps saving a few keystrokes by using the . repeat feature to do each…

Michael Durrant
- 42,013
149
votes
9 answers
What's the most appropriate directory where to place files shared between users?
Or: where can I put files belonging to a group?
Suppose there are two users on a Unix system: joe and sarah. They are both members of the movies-enthusiast group. Where should I put their movie files?
/home/{joe,sarah}/movies are not appropriate…

user16538
- 1,803
- 3
- 13
- 9
149
votes
1 answer
How to prettyprint json using jq standalone?
Currently, when I want to pretty-print a json file using jq, I use:
cat file.json | jq .
Yet I would expect for jq to accept a file name as argument without having to fallback on cat.
The man page says:
jq [options...] filter [files...]
...
By…

k0pernikus
- 15,463
149
votes
2 answers
exit tmux window without quitting the Terminal program
OK I'm new to this. I installed tmux to run a several days experiment. After typing tmux new -s name I got a new window with green banner at the bottom. I compile and run java program. Now I do not know how to exit the window (while leave it…

seteropere
- 1,609
- 2
- 11
- 5
149
votes
13 answers
Replace space between filepaths with newline
How can I replace spaces with new lines on an input like:
/path/to/file /path/to/file2 /path/to/file3 /path/to/file4 /path/to/file5 etc...
To obtain the following:
/path/to/file
/path/to/file2
/path/to/file3
/path/to/file4
/path/to/file5
Note
I'm…

laconbass
- 4,409
- 4
- 17
- 20
148
votes
9 answers
Exit vim more quickly
I use Vim mainly for quick edits rather than long work sessions. In that sense, I find the keyboard sequence for quitting especially laborious: Esc, Shift + ;, w, q, Enter.
How to quit Vim (possibly saving the document) with the least keystrokes?…

deprecated
- 2,361
- 4
- 24
- 23
148
votes
6 answers
How to monitor only the last n lines of a log file?
I have a growing log file for which I want to display only the last 15 lines. Here is what I know I can do:
tail -n 15 -F mylogfile.txt
As the log file is filled, tail appends the last lines to the display.
I am looking for a solution that only…

Marc-Olivier Titeux
- 1,613
148
votes
2 answers
How to uninstall a .deb installed with dpkg?
I installed Unified Remote using dpkg:
dpkg -i urserver.deb
How do I uninstall it so I can reinstall from scratch?

Tomblarom
- 2,117
148
votes
1 answer
How does the OOM killer decide which process to kill first?
This answer explains the actions taken by the kernel when an OOM situation is encountered based on the value of sysctl vm.overcommit_memory.
When overcommit_memory is set to 0 or 1, overcommit is enabled, and programs are allowed to allocate more…

Ramesh
- 39,297
148
votes
14 answers
List partition labels from the command line
Is there a command that will list all partitions along with their labels? sudo fdisk -l and sudo parted -l don't show labels by default.
EDIT: (as per comment below) I'm talking about ext2 labels - those that you can set in gparted upon…

sdaau
- 6,778
147
votes
6 answers
difference between "function foo() {}" and "foo() {}"
I can define bash functions using or omitting the function keyword. Is there any difference?
#!/bin/bash
function foo() {
echo "foo"
}
bar() {
echo "bar"
}
foo
bar
Both calls to functions foo and bar succeed and I can't see any difference.…

Carlos Campderrós
- 2,111
- 2
- 16
- 18
147
votes
6 answers
apache2 Invalid command 'SSLEngine'
When I restart httpd, I get the following error. What am I missing?
[root@localhost ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: Syntax error on line 22 of…

Christian
- 2,195