Most Popular

1500 questions
146
votes
3 answers

Recursive glob?

I'd like to write something like this: $ ls **.py in order to get all .py filenames, recursively walking a directory hierarchy. Even if there are .py files to find, the shell (bash) gives this output: ls: cannot access **.py: No such file or…
Paolo
  • 16,955
  • 11
  • 31
  • 40
146
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,593
  • 2
  • 10
  • 8
144
votes
10 answers

Is there a way to see details of all the threads that a process has in Linux?

For Windows, I think Process Explorer shows you all the threads under a process. Is there a similar command line utility for Linux that can show me details about all the threads a particular process is spawning? I think I should have made myself…
Lazer
  • 34,477
  • 25
  • 70
  • 75
144
votes
5 answers

How to escape quotes in shell?

I'm having trouble with escaping characters in bash. I'd like to escape single and double quotes while running a command under a different user. For the purposes of this question let's say I want to echo the following on the screen: 'single quote…
m33lky
  • 2,505
  • 5
  • 22
  • 20
144
votes
7 answers

How to kill a runaway cat?

Many times I accidentally run the cat command on files that have contents up to few thousand lines. I try to kill the cat command with Ctrl+ C or Ctrl+Z, but both only take effect after the total output of cat is displayed in the terminal, so I have…
JigarGandhi
  • 4,820
  • 10
  • 27
  • 38
144
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
  • 38,687
  • 43
  • 140
  • 215
144
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,668
  • 12
  • 57
  • 69
143
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,723
  • 3
  • 12
  • 9
143
votes
7 answers

Error using SCP: "not a regular file"

I have been searching for a while and I can't find the definition of a regular file. My path is permanent (I start at /) and I am connecting to scp root@IP: /path/to/picture.jpg Results in an inquiry for a password and then... scp: .: not a regular…
JeffM
  • 1,533
  • 2
  • 10
  • 6
143
votes
11 answers

What is the difference between $* and $@?

Consider the following code: foo () { echo $* } bar () { echo $@ } foo 1 2 3 4 bar 1 2 3 4 It outputs: 1 2 3 4 1 2 3 4 I am using Ksh88, but I am interested in other common shells as well. If you happen to know any particularity for…
rahmu
  • 19,673
  • 28
  • 87
  • 128
143
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,045
  • 5
  • 20
  • 11
143
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,549
  • 2
  • 10
  • 5
142
votes
8 answers

Is there a tool to get the lines in one file that are not in another?

Is there any tool that can get lines which file A contains, but file B doesn't? I could make a little simple script with, e.g, perl, but if something like that already exists, I'll save my time from now on.
daisy
  • 53,527
  • 78
  • 236
  • 383
142
votes
6 answers

What are other ways to share a tmux session between two users?

I'm looking for a clean and easy way to share a tmux session with another user on the same machine. I've tried the -S socket-path option, but it requires opening up all permissions of the socket-path before someone else can connect to the session. …
Ryan McGeary
  • 1,525
  • 2
  • 10
  • 8
142
votes
7 answers

When is xargs needed?

The xargs command always confuses me. Is there a general rule for it? Consider the two examples below: $ \ls | grep Cases | less prints the files that match 'Cases', but changing the command to touch will require xargs: $ \ls | grep Cases |…
Zaid
  • 10,442
  • 13
  • 38
  • 36