81
votes
3answers
28k views

Why do directories need the executable (X) permission to be opened?

In my CMS, I noticed that directories need the executable bit (+x) set for the user to open them. Why is the execute permission required to read a directory?
64
votes
5answers
10k views

Why is it better to use “#!/usr/bin/env NAME” instead of “#!/path/to/NAME” as my shebang?

I notice that some scripts which I have acquired from others have the shebang #!/path/to/NAME while others (using the same tool, NAME) have the shebang #!/usr/bin/env NAME. Both seem to work ...
26
votes
7answers
4k views

Non-Root Package Managers

From my research, I seem to notice that all package managers insist on being used as a privileged user and must be installed into /. Typically, what I like to do is create a throwaway account, ...
19
votes
7answers
1k views

Good Introductory resources for linux [closed]

Are there any good tutorials or resources I can read so that I am not confused by basic things like 'how to search all files in a directory and below for a given string', or 'how to find out how much ...
37
votes
4answers
7k views

What's the point in adding a new line to the end of a file?

Some compilers (especially C or C++ ones) give you warnings about: No new line at end of file I thought this would be a C-programmers-only problem, but github displays a message in the commit view: ...
10
votes
4answers
6k views

What should I do before dual-booting Windows 7 and Debian on EFI?

I'm about to purchase an Asus motherboard with EFI firmware and wanted to prepare myself for installing Windows and Debian once the hardware arrives. I was hoping that someone who has gone down this ...
9
votes
3answers
14k views

Output traffic on different interfaces based on destination port

My question is basically the same as Only allow certain outbound traffic on certain interfaces. I have two interfaces eth1 (10.0.0.2) and wlan0 (192.168.0.2). My default route is for eth1. Let's say ...
13
votes
4answers
3k views

Is it possible to find out what program or script created a given file?

Three files have suddenly appeared in my home directory, called "client_state.xml", "lockfile", and "time_stats_log". The last two are empty. I'm wondering how they got there. It's not the first time ...
21
votes
3answers
11k views

Why can't a normal user `chown` a file?

Why is the chown command root-only? Why can't non-root users use chown to give away files they own?
9
votes
3answers
8k views

sending text input to a detached screen

I'm trying to run a minecraft server on my unRAID server. The server will run in the shell, and then sit there waiting for input. To stop it, I need to type 'stop' and press enter, and then it'll ...
96
votes
10answers
30k views

Turn off buffering in pipe

I have a script which calls two commands: long_running_command | print_progress The long_running_command prints a progress but I'm unhappy with it. I'm using print_progress to make it more nice ...
39
votes
4answers
22k views

How does reverse SSH tunneling work?

As I understand this, firewalls (assuming default settings) deny all incoming traffic that has no prior corresponding outgoing traffic. Based on Reversing an ssh connection and SSH Tunneling Made ...
18
votes
4answers
29k views

How to make a machine accessible from the LAN using its hostname

Here are details of the machine I want to access using its hostname: $ hostname hostname $ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 hostname.company.local hostname It's a default Debian 6 ...
11
votes
7answers
620 views

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 ...
18
votes
2answers
641 views

Why does my shell script choke on whitespace or other special characters?

Or, an introductory guide to robust filename handling and other string passing in shell scripts. I wrote a shell script which works well most of the time. But it chokes on some inputs (e.g. on some ...
23
votes
4answers
12k views

Why do we use “./” to execute a file?

Why do we use ./filename to execute a file in linux? Why not just enter it like other commands gcc, ls etc...
8
votes
3answers
2k views

Automating web requests using curl?

I have some "corporative" systems I have to use at work. Some of them are terrible, with frames, pop-ups and such. I was thinking about automating some stuff using curl or something like that. I need ...
4
votes
2answers
4k views

ext4: How to account for the filesystem space?

I've recently formated a 1.5 TB drive with the intention of replacing ntfs with ext4. Then I noticed that the files I saved don't fit on the new partition. df: ext4 (ext3 & ext2 show the same ...
8
votes
4answers
2k views

32-bit, 64-bit CPU op-mode on Linux

I'm confused. Running Fedora Linux, lscpu yields: Architecture: i686 CPU op-mode(s): 32-bit, 64-bit ... But when I try to install a 64-bit program (Chrome) I get error like: ...
133
votes
12answers
89k views

What if 'kill -9' does not work?

I have a process I can't kill with kill -9 <pid>. What's the problem in such a case, especially since I am the owner of that process. I thought nothing could evade that kill option.
52
votes
14answers
67k views

Why am I still getting a password prompt with ssh with public key authentication?

I'm working from the URL I found here: http://jaybyjayfresh.com/2009/02/04/logging-in-without-a-password-certificates-ssh/ My ssh client is Ubuntu 64 bit 11.10 desktop and my server is Centos 6.2 64 ...
38
votes
4answers
6k views

Convince grep to output all lines, not just those with matches

Say I have the following file: $ cat test test line 1 test line 2 line without the search word another line without it test line 3 with two test words test line 4 By default, grep returns each ...
47
votes
12answers
16k views

Get exit status of process that's piped to another

I have two processes foo and bar, connected with a pipe: $ foo | bar bar always exits 0; I'm interested in the exit code of foo. Is there any way to get at it?
21
votes
3answers
14k views

Restricting an SSH/SCP/SFTP user to a directory

Is there a simple way to restrict an SCP/SFTP user to a directory? All methods that I've come across require me to set a chroot jail up by copying binaries, but I don't think that should be necessary. ...
26
votes
7answers
5k views

Is there a way to modify a file in-place?

I have a fairly large file (35Gb), and I would like to filter this file in situ (i.e. I don't have enough disk space for another file), specifically I want to grep and ignore some patterns — is there ...
29
votes
7answers
11k views

How to test what shell I am using in a terminal?

How to check what shell I am using in a terminal? What is the shell I am using in MacOS?
19
votes
2answers
9k views

How can I make iconv replace the input file with the converted output?

I have a bash script which enumerates through every *.php file in a directory and applies iconv to it. This gets output in STDOUT. Since adding the -o parameter ( in my experience ) actually writes ...
12
votes
1answer
795 views

When is double-quoting necessary?

The old advice used to be to double-quote any expression involving a $VARIABLE, at least if one wanted it to be interpreted by the shell as one single item, otherwise, any spaces in the content of ...
25
votes
4answers
1k views

Quick way to include a directory path when calling mv? [duplicate]

Often I will work out of the root of a rails directory where I find my self navigating the same path twice every time I would like to move a file: mv app/views/layouts/application.html.erb ...
23
votes
4answers
4k views

When would you use an additional file descriptor?

I know you can create a file descriptor and redirect output to it. e.g. exec 3<> /tmp/foo # open fd 3. echo a >&3 # write to it exec 3>&- # close fd 3. But you can do the same ...
22
votes
2answers
6k views

What mount points exist on a typical Linux system?

I have 2 questions. During Linux installation we specify memory space for 2 mount points - root and swap. Are there any other mount points created without the users notice? Is this statement ...
14
votes
2answers
828 views

gnu find and masking the {} for some shells - which?

The man page for gnu find states: -exec command ; [...] The string `{}' is replaced by the current file name being processed everywhere it occurs in the arguments to the command, ...
23
votes
6answers
5k views

what does the @ mean in ls -l?

I am using Mac OSX. When I type ls -l I see something like drwxr-xr-x@ 12 xonic staff 408 22 Jun 19:00 . drwxr-xr-x 9 xonic staff 306 22 Jun 19:42 .. -rwxrwxrwx@ 1 xonic staff 6148 25 ...
2
votes
1answer
3k views

How can I fix/install/reinstall grub?

So I started out with a 250GB HDD, the stock drive from an EeePC 1015pem that I am trying to turn into a MintBook. The drive is physically operable, but all data has been nuked, including the old OS. ...
1
vote
1answer
2k views

“No such file or directory” lies on Optware installed binaries

I've been using Optware to install packages on my ARM-based NAS for a while - the usual stuff like Transmission, Samba and others. However, I'd been having problems with Transmission hanging not long ...
34
votes
8answers
42k views

Looping through files with spaces in the names?

I wrote the following script to diff the outputs of two directores with all the same files in them as such: #!/bin/bash for file in `find . -name "*.csv"` do echo "file = $file"; diff ...
37
votes
4answers
3k views

What features are in zsh and missing from bash, or vice versa?

As a Linux user, I've always just used bash because it was the default on every distro I used. People using other Unix systems such as BSD seem to use other shells far more frequently. In the ...
40
votes
3answers
5k views

What exactly is POSIX?

I see POSIX mentioned often and everywhere, and I had assumed it to be the baseline UNIX standard.. until I noticed the following excerpt on a Wikipedia page: The Open Group The Open Group is ...
31
votes
2answers
12k views

Why can rm remove read-only files?

If I create a file and then change its permissions to 444 (read-only), how come rm can remove it? If I do this: echo test > test.txt chmod 444 test.txt rm test.txt ...rm will ask if I want to ...
16
votes
1answer
11k views

How to loop over the lines of a file?

Say I have this file: hello world hello world This program #!/bin/bash for i in $(cat $1); do echo "tester: $i" done outputs tester: hello tester: world tester: hello tester: world I'd ...
16
votes
4answers
4k views

Four tasks in parallel… how do I do that?

I have a bunch of PNG images on a directory. I have an application called pngout that I run to compress these images. This application is called by a script I did. The problem is that this script does ...
26
votes
3answers
5k views

using single or double bracket - bash

I'm confused with using single or double bracket. look at code: dir="/home/mazimi/VirtualBox VMs" if [[ -d ${dir} ]]; then echo "yep" fi It works perfectly although the string contains space. ...
22
votes
5answers
11k views

Determine which process is creating a file

Given file path, how can I determine which process creates it (and/or reads/writes to it)?
18
votes
9answers
6k views

Is there a robust command line tool for processing csv files?

I work with CSV files and sometimes need to quickly check the contents of a row or column from the command line. In many cases cut, head, tail, and friends will do the job; however, cut cannot easily ...
32
votes
4answers
22k views

Reserved space for root on a filesystem - why?

I understand that by default, newly created filesystems will be created with 5% of the space allocated for root. I also know you can change the defined space with: tune2fs -m 1 /dev/sdXY What I'm ...
21
votes
3answers
9k views

Understanding IFS

The following few threads on this site and StackOverflow were helpful for understanding how IFS works: What is IFS in context of for looping? How to loop over the lines of a file Bash, read line by ...
15
votes
4answers
7k views

Removing control chars (including console codes / colours) from script output

I can use the "script" command to record an interactive session at the command line. However, this includes all control characters and colour codes. I can remove control characters (like backspace) ...
8
votes
4answers
3k views

Evolution of Operating systems from Unix

Can you explain the evolution hierarchy of operating systems (Linux and Windows) from Unix?
6
votes
4answers
3k views

How do I connect to a pc through another pc using ssh

I have three Computers. PC1 and PC2 is on a private LAN, where PC1 is known to PC2 as 192.168.0.2 PC2 and PC3 is on a another LAN, where PC2 is known to PC3 as 192.168.123.101 How can I connect to ...
22
votes
2answers
8k views

What do the brackets around processes mean?

mark@mark-VirtualBox:~/auto/lib$ ps -Awwo pid,comm,args PID COMMAND COMMAND 1 init /sbin/init 2 kthreadd [kthreadd] 3 ksoftirqd/0 [ksoftirqd/0] 5 ...

15 30 50 per page