Most Popular

1500 questions
81
votes
4 answers

What's the standard for indentation in shell scripts?

Java community use 4 spaces as the unit of indentation. 1 Ruby community use 2 spaces that is generally agreed-upon. 2 What's the standard for indentation in shell scripts? 2 or 4 spaces or 1 tab?
81
votes
7 answers

How many shells deep I am?

Problem: Find how many shells deep I am. Details: I open the shell from vim a lot. Build and run and exit. Sometimes I forget and open another vim inside and then yet another shell. :( I want to know how many shells deep I am, perhaps even have it…
Pranay
  • 961
81
votes
1 answer

What is the difference between a name and a label in gparted?

When I create a new partition on my disk using GParted, I have the option to set both a name and a label. Some partitions I have already have both, some only a label. If I right-click on an existing partition, I can see separate options to set the…
user168419
81
votes
5 answers

How to check 'mdadm' RAIDs while running?

I'm starting to get a collection of computers at home and to support them I have my "server" linux box running a RAID array. Its currently mdadm RAID-1, going to RAID-5 once I have more drives (and then RAID-6 I'm hoping for). However I've heard…
81
votes
3 answers

Is space allowed between #! and /bin/bash in shebang?

In a shebang, is a space or more allowed between #! and the interpreter? For example, #! /bin/bash. It seems work, but some said that it is incorrect.
Tim
  • 101,790
81
votes
5 answers

How can I show a terminal shell's process tree including children?

When a script is launched from command prompt the shell will spawn a subprocess for that script. I want to show that relationship between terminal level process and its children using ps in a tree style output. How can I do this? What I have tried…
81
votes
4 answers

$@ except the 1st argument

I need to write a shell script that runs in this way: ./myscript arg1 arg2_1 arg2_2 arg2_3 ....... arg2_# there is a for loop inside script for i in $@ However, as I know, $@ includes $1 up to $($#-1). But for my program $1 is distinctly…
user40780
  • 1,941
81
votes
9 answers

Why do we need to mount on Linux?

I understand what mounting is in Linux, and I understand device files. However I do not understand WHY we need to mount. For example, as explained in the accepted answer of this question, using this command: mount /dev/cdrom /media/cdrom we are…
Greeso
  • 913
  • 1
  • 7
  • 8
81
votes
6 answers

Get path of current script when executed through a symlink

I have a utility consisting of a couple of directories with some bash scripts and supporting files that will be deployed to several machines, possibly in a different directory on each machine. The scripts need to be able to reference paths relative…
Mike Deck
  • 1,413
81
votes
9 answers

How do I send HTML email using linux 'mail' command?

mail -s "subject" xxxxx@gmail.com
pyth0ner
  • 911
81
votes
8 answers

What is a better way to deal with server disconnects of sshfs mounts?

I have several directories mounted through sshfs. I sometimes get disconnects from the server (not configurable by me). I usually mount the directories like this sshfs user@server.example.com:/home/user /mnt/example When a server disconnects, the…
Sebastian
  • 8,817
  • 4
  • 40
  • 49
81
votes
5 answers

How to determine which process is creating a file?

Given file path, how can I determine which process creates it (and/or reads/writes to it)?
81
votes
8 answers

Dark blue color in vim or ls output in linux

I have a problem with dark-blue color in vim or ls output. Because I'm using black background color, words colored in dark-blue are almost completely invisible. How can I address this problem?
user7477
81
votes
3 answers

How can I view gzipped files in less without having to type zless?

I am using Ubuntu, and I would like to be able to type less compressed_text_file.gz and page the contents of the text file in uncompressed form. Is there a way to do this?
81
votes
10 answers

How to turn off color with `ls`?

It is normally nice to have color output from ls, grep, etc. But when you don't want it (such as in a script where you're piping the results to another command) is there a switch that can turn it off? ls -G turns it on (with some BSD-derived…
iconoclast
  • 9,198
  • 13
  • 57
  • 97