175
votes
5answers
67k views

What does env x='() { :;}; command' bash do and why is it insecure?

There is apparently a vulnerability (CVE-2014-6271) in bash: https://securityblog.redhat.com/2014/09/24/bash-specially-crafted-environment-variables-code-injection-attack/ I am trying to figure out ...
93
votes
13answers
35k views

How to have tail -f show colored output

I'd like to be able to tail the output of a server log file that has messages like: INFO SEVERE etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I ...
44
votes
3answers
6k 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 ...
20
votes
1answer
15k 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 ...
18
votes
4answers
5k 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 ...
19
votes
5answers
9k 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) ...
17
votes
6answers
541 views

Reading and searching long man pages

I finally got fed up when wanting to read about bash's read and it's -s option with man bash. I found the right spot eventually (around line 4500), but it was a frustrating as usual, since both /read ...
10
votes
4answers
3k views

Evolution of Operating systems from Unix

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

Automatically run commands over SSH on many servers

There is a list of IP addresses in a .txt file, ex.: 1.1.1.1 2.2.2.2 3.3.3.3 Behind every IP address there is a server, and on every server there is an sshd running on port 22. Not every server is ...
6
votes
4answers
4k 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 ...
24
votes
2answers
9k 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 ...
23
votes
8answers
7k views

How to understand what's taking up space?

I'm looking for a linux alternative to WinDirStat. I would like to know what is taking up space on my hard drives. A program that works on console and doesn't require a UI is preferred .
15
votes
6answers
2k views

Any way to sync directory structure when the files are already on both sides?

I have two drives with the same files, but the directory structure is totally different. Is there any way to 'move' all the files on the destination side so that they match the structure of the ...
14
votes
3answers
3k views

Determining Specific File Responsible for High I/O

This is a simple problem but the first time I've ever had to actually fix it: finding which specific files/inodes are the targets of the most I/O. I'd like to be able to get a general system overview, ...
4
votes
2answers
1k views

How to make password-less login work

I generated a key and copied it to my target: ssh-keygen ssh-copy-id username@hostname I left the the location of the key as default and did not set any passphrase. For a small while after that, I ...
8
votes
3answers
3k views

Can't access select https sites on Linux over PPPoE

My internet connection used to be a direct LAN connection to my provider. Back then, everything would load fine on both Windows and Ubuntu (dual boot). However, a while ago they started needing me to ...
6
votes
2answers
2k views

Why is there a discrepancy in disk usage reported by df and du? [duplicate]

I have a Linux(CentOS) server, the OS+packages used around 5GB. Then, I transferred 97GB data from a Windows server to two folders on this Linux server, after calculated the disk usage, I see the ...
6
votes
5answers
1k views

How to clean up file extensions?

I have a directories with .MP3 files which I'd like to change the extensions to .mp3. What's the easiest way to do this? I'm think something along the lines of: find /RootPath -type f -iname "*.mp3" ...
10
votes
2answers
3k views

real memory usage

if I understand correctly, in the following output produced by free, 3535m is the actual free memory available to applications, only 413m is used, is this correct? need some clarification on the ...
6
votes
2answers
3k views

How can I rename a lot of files using a regex?

I want to rename a lot of files on Mac OS X (10.7.2).. I don't have the perl package for the rename command. My files have names like "T452-102456-0.png" and I want to delete the "-0" part. I know I ...
284
votes
7answers
24k views

Where is implemented the definitions of the kernel header files?

I am trying to understand how a function, say mkdir, works by looking at the kernel source. This is an attempt to understand the kernel internals and navigate between various functions. I know mkdir ...
106
votes
3answers
49k views

How to unfreeze after accidentally pressing Ctrl-S in a terminal?

It's a situation that has happened quite often to me: after I press (with a different intention) Ctrl-S in a terminal, the interaction (input or output) with it is frozen. It's probably a kind of ...
63
votes
6answers
138k views

How to forward X over SSH from Ubuntu machine?

I have a machine running Ubuntu which I SSH to from my Fedora 14 machine. I want to forward X from the Ubuntu machine back to Fedora so I can run graphical programs remotely. Both machines are on a ...
75
votes
2answers
10k views

Why do we use su - and not just su?

I don't understand why su - is preferred over su to login as root.
88
votes
2answers
16k views

When was the shellshock (CVE-2014-6271/7169) bug introduced, and what is the patch that fully fixes it?

Some context about the bug: CVE-2014-6271 Bash supports exporting not just shell variables, but also shell functions to other bash instances, via the process environment to (indirect) child ...
100
votes
9answers
8k views

The myths about malware in unix/linux

Is it possible for my Linux box to become infected with a malware? I haven't heard of it happening to anyone I know, and I've heard quite a few times that it isn't possible. Is that true? If so, ...
49
votes
6answers
1k views

Resources for portable shell programming

What resources exist for portable shell programming? The ultimate answer is to test on all targeted platforms, but that's rarely practical. The POSIX / Single UNIX specification is a start, but it ...
43
votes
6answers
17k views

How can I move files and view the progress (e.g. with a progress bar)?

When moving large directories using mv, is there a way to view the progress (%)? The cp command on gentoo had a -g switch that showed the progress.
39
votes
5answers
29k views

What is a Superblock, Inode, Dentry and a File?

From the article Anatomy of Linux File Systems by Tim Jones, I read that Linux views all the file systems from the perspective of a common set of objects and these objects are superblock, inode, ...
77
votes
6answers
6k views

Why is cd not a program?

I've always wondered why cd isn't a program, but never managed to find the answer. Anyone know why this is the case?
32
votes
5answers
5k views

Timing out in a shell script

I have a shell script that's reading from standard input. In rare circumstances, there will be no one ready to provide input, and the script must time out. In case of timeout, the script must execute ...
30
votes
4answers
3k views

Using '.' to execute files in bash

What's the difference between executing a script like this: ./test.sh and executing a script like this: . test.sh? I tried a simple, two-line script to see if I could find if there was a ...
50
votes
6answers
18k views

Can I create a user-specific hosts file to complement /etc/hosts?

Is it possible to add a list of hosts that are only specific to a certain user? Perhaps a user-specific hosts file? This mechanism should also complement the entries in the /etc/hosts file.
17
votes
1answer
1k views

Configuring, compiling and installing a custom Linux kernel

I'd like to try using a kernel other than the one provided by my distro -- either from somewhere else, or as customized by me. Is this difficult or dangerous? Where do I start?
21
votes
1answer
828 views

How do keyboard input and text output work?

Suppose I press the A key in a text editor and this inserts the character a in the document and displays it on the screen. I know the editor application isn't directly communicating with the hardware ...
10
votes
7answers
15k views

Unix/Linux undelete/recover deleted files

Is there a command to recover/undelete deleted files by rm? $ rm -rf /path/to/myfile How can I recover myfile? If there is such a tool how can I use it?
9
votes
1answer
7k views

File descriptors & shell scripting

I am having a very hard time understanding how does one use file descriptors in shell scripts. I know the basics such as exec 5 > /tmp/foo So fd 5 is attached to foo for writing. exec 6 < ...
4
votes
2answers
289 views

What are the shell's control and redirection operators?

I often see tutorials online that connect various commands with different symbols. For example: command1 | command2 command1 & command2 command1 || command2 command1 && command2 ...
22
votes
3answers
18k views

Installing Grub 2 on a USB flash drive

MultiBootISOs is a tool that let you install Grub on a USB flash drive. I really like it because it lets me boot from ISO files and let me put a bunch of ISOs on my USB and choose which one to boot. ...
12
votes
1answer
2k views

Can one PC be used by two users at the same time via dual-monitor?

Since modern PCs can use two screens at the same time I wonder if it is possible to plug in two keyboards and mouses as well to have the two screens run two (more or less) independent X-sessions at ...
20
votes
2answers
4k views

When is dd suitable for copying data? (or, when are read() and write() partial)

Short version: In what circumstances is dd safe to use for copying data, safe meaning that there is no risk of corruption due to a partial read or write? Long version — preamble: dd is often used to ...
12
votes
4answers
3k views

The merits of a partitionless filesystem

I ran into something a couple of weeks ago that I'd never seen before: A filesystem (ext3 I believe) installed to a storage device without a partition. In essence /dev/sdb was the entire filesystem. I ...
12
votes
2answers
6k views

Debian based system, only one gui program, nothing else

I would like to make a debian system where you can only open one GUI program at boot, no other graphical interface, no minimize, or any X apart from that program, is there a way to do it on debian if ...
11
votes
3answers
7k views

How to find out which (not installed) package a file belongs to?

On Debian systems (and derivatives): $ dpkg --search /bin/ls coreutils: /bin/ls That is, the file /bin/ls belongs to the Debian package named coreutils. But this only works if the package is ...
7
votes
2answers
2k views

Find filesystem of an unmounted partition from a script

I'm writing a custom automated install using AIF (Arch Installation Framework), and I need to find the filesystem on a partition given a partition. So far I have this: grok_partitions () { local ...
7
votes
2answers
9k views

Extracting a regex matched with 'sed' without printing the surrounding characters

To all the 'sed' doctors out there: I have a seemingly trivial 'sed' question to which I have not been able to find a solution. How can you get 'sed' to exctract a regular expression it has matched ...
7
votes
2answers
4k views

ssh port forward to access my home machine from anywhere

http://serverfault.com/questions/303937/how-to-make-freebsd-box-accessible-from-internet I want to understand this whole process of port forwarding. I read so many things but failing to understand ...
6
votes
2answers
7k views

Why is my variable being localized in one 'while read' loop, but not in another seemingly similar loop [duplicate]

Why do I get different values for $x from the snippets below? #!/bin/bash x=1 echo fred>junk ; while read var ; do x=55 ; done <junk echo x=$x # x=55 .. I'd expect this result x=1 cat ...
4
votes
6answers
16k views

Changing extension to multiple files

I would like to change file extension from *.txt file to *.text file, tried using the basename command, but I am having trouble on changing more than 1 file, I am getting a basename: too many ...
10
votes
6answers
662 views

How can I cleanly add to $PATH?

I'd like a way to add things to $PATH, system-wide or for an individual user, without potentially adding the same path multiple times. One reason to want to do this is so that additions can be made ...

15 30 50 per page