237
votes
4answers
42k views
What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?
I think these terms almost refer to the same thing, when used loosely:
terminal
shell
tty
console
What exactly do each of these terms refer to?
37
votes
6answers
11k views
How can I disown a running process and associate it to a new screen shell?
I have a running program on a SSH shell. I want to pause it and be able to unpause its execution when I come back.
One way I thought of doing that was to transfer its ownership to a screen shell, ...
25
votes
5answers
6k views
How do I run a command as the system administrator (root)
I need to run a command with administrative privileges. Someone said I should run a command as root. How do I do this?
11
votes
2answers
4k views
Getting “Not found” message when running a 32-bit binary on a 64-bit system
I have currently a strange problem on debian (wheezy/amd64).
I have created a chroot to install a server (i can't give any more detail about it, sorry). Let's call its path /chr_path/.
To make things ...
21
votes
4answers
1k views
Alternative to .bashrc
Is ~/.bashrc the only place where I can specify user specific ENV Variables, aliases, modifications to PATH variable, etc?
I ask because it seems that ~/.bashrc would be bash only...
25
votes
4answers
2k views
Redirecting stdout to a file you don't have write permission on
When you attempt to modify a file without having write permissions on it, you get an error:
> touch /tmp/foo && sudo chown root /tmp/foo
> echo test > /tmp/foo
zsh: permission ...
8
votes
4answers
20k views
Open a window on a remote X display (why “Cannot open display”)?
Once upon a time,
DISPLAY=:0.0 totem /path/to/movie.avi
after ssh 'ing into my desktop from my laptop would cause totem to play movie.avi on my desktop.
Now it gives the error:
No protocol ...
20
votes
4answers
6k views
Why is `while IFS= read` used so often, instead of `IFS=; while read..`?
It seems that normal practice would put the setting of IFS outside the while loop in order to not repeat setting it for each iteration... Is this just a habitual "monkey see, monkey do" style, as it ...
47
votes
5answers
3k views
What do the numbers in a man page mean?
So, for example, when I type man ls I see LS(1). But if I type man apachectl I see APACHECTL(8) and if I type man cd I end up with cd(n).
I'm wondering what the significance of the numbers in the ...
24
votes
2answers
2k views
$VAR vs ${VAR} and to quote or not to quote
I can write
VAR=$VAR1
VAR=${VAR1}
VAR="$VAR1"
VAR="${VAR1}"
the end result to me all seems about the same. Why should I write one or the other? are any of these not portable/POSIX?
21
votes
4answers
10k views
Moving linux install to a new computer
I know that it can, in some circumstances, be difficult to move a Windows installation from one computer to another (physically move the hard drive), but how does that work on linux? Aren't most of ...
10
votes
3answers
3k views
Can I launch a graphical program on another user's desktop as root?
Following are other questions which I think I need to know:
From a non X Session? (meaning root isn't logged into X)
If multiple people were logged in on X, could I auto-detect who was on which ...
53
votes
6answers
6k views
Is Linux a Unix?
So, there are lots of different versions of Unix out there: HP-UX, AIX, BSD, etc. Linux is considered a Unix clone rather than an implementation of Unix. Are all the "real" Unices actual descendants ...
17
votes
3answers
4k views
How to pass parameters to an alias?
For bash script, I can use "$@" to access arguments. What's the equivalent when I use an alias?
51
votes
9answers
9k views
Preserve bash history in multiple terminal windows
I consistently have more than one terminal open. Anywhere from two to ten, doing various bits and bobs. Now let's say I restart and open up another set of terminals. Some remember certain things, some ...
29
votes
11answers
21k views
How can I get distribution name and version number in a simple shell script?
I'm working on a simple bash script that should be able to run on Ubuntu and CentOS distributions (support for Debian and Fedora/RHEL would be a plus) and I need to know the name and version of the ...
33
votes
5answers
18k views
Allow setuid on shell scripts
The setuid permission bit tells Linux to run a program with the effective user id of the owner instead of the executor:
> cat setuid-test.c
#include <stdio.h>
#include <unistd.h>
int ...
19
votes
7answers
12k views
Rsync filter: copying one pattern only
I am trying to create a directory that will house all and only my PDFs compiled from LaTeX. I like keeping each project in a separate folder, all housed in a big folder called LaTeX. So I tried ...
11
votes
4answers
3k views
Recovering deleted files on fedora
I accidentally deleted a file from my laptop. I'm using Fedora. Is it possible to recover the file?
9
votes
3answers
7k views
Make all new files in a directory accessible to a group
Suppose I have two users A and B and a group G and a folder foo, both users are members of G (using linux and ext3).
If I save as user A a file under foo, the permissions are: -rw-r--r-- A A. ...
13
votes
4answers
33k views
How do I set a user environment variable? (permanently, not session)
This is irritating me. I seen several suggestions (all using different files and syntax) and none of them worked.
How do I set an environment variable for a specific user? I am on debian squeeze.
...
31
votes
2answers
7k views
What does “--” (double-dash) mean?
I have seen -- used in the compgen command.
For example:
compgen -W "foo bar baz" -- b
What is the meaning of the --.
27
votes
7answers
3k views
How do I delete a file whose name begins with “-” (hyphen a.k.a. dash or minus)?
How do you remove a file whose filename begins with a dash (hyphen or minus) -? I'm ssh'd into a remote OSX server and I have this file in my directory:
tohru:~ $ ls -l
total 8
-rw-r--r-- 1 me ...
23
votes
3answers
2k views
How to use `which` on an aliased command?
Like most users, I have a bunch of aliases set up to give a default set of flags for frequently used programs. For instance,
alias vim='vim -X'
alias grep='grep -E'
alias ls='ls -G'
The problem is ...
8
votes
4answers
1k 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 ...
33
votes
6answers
3k views
How linux handles multiple path separators (/home////username///file)
I'm working on a python script that passes file locations to an scp subprocess. That's all fine, but I'm in a situation where I may end up concatenating a path with a filename such that there's a ...
18
votes
2answers
6k views
How do I run 32-bit programs on a 64-bit Ubuntu?
I have a 64-bit (amd64 a.k.a. x86_64) Debian or Ubuntu installation. I need to run 32-bit (i386/i686) programs occasionally, or to compile programs for a 32-bit system. How can I do this with a ...
41
votes
3answers
17k views
How do I read from /proc/$pid/mem under Linux?
The Linux proc(5) man page tells me that /proc/$pid/mem “can be used to access the pages of a process's memory”. But a straightforward attempt to use it only gives me
$ cat /proc/$$/mem ...
22
votes
7answers
2k 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, ...
14
votes
4answers
3k views
Is there a way to determine the optimal value for the bs parameter to dd?
On occasion I've seen comments online along the lines of "make sure you set 'bs=' because the default value will take too long," and my own extremely-unscientific experiences of, "well that seemed to ...
19
votes
2answers
3k 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 ...
7
votes
4answers
10k 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 ...
19
votes
5answers
5k 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?
4
votes
3answers
677 views
Does anybody here have experience in automating some tasks in web applications 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 ...
8
votes
4answers
13k views
How to run a specific program as root without a password prompt?
I need to run something as sudo without a password, so I used visudo and added this to my sudoers file:
MYUSERNAME ALL = NOPASSWD: /path/to/my/program
Then I tried it out:
$ sudo ...
95
votes
9answers
7k views
In Bash, when to alias, when to script, and when to write a function?
It's taken me almost 10 years of Linux usage to ask this question. It was all trial and error and random late-night internet surfing.
But people shouldn't need 10 years for this. If I were just ...
41
votes
6answers
4k views
dd vs cat — is dd still relevant these days?
I recently realized we can use cat as much as dd, and it's actually faster than dd
I know that dd was useful in dealing with tapes where block size actually mattered in correctness, not just ...
32
votes
4answers
14k views
How can I close a terminal without killing the command running in it?
Sometimes I want to start a process and forget about it. If I start it from the command line, like this:
redshift
I can't close the terminal, or it will kill the process. Can I run a command in ...
14
votes
7answers
802 views
Good Introductory resources for linux
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 ...
8
votes
4answers
3k 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 ...
13
votes
3answers
2k views
Difference between Login Shell and Non-Login Shell?
I understand the basic difference between an interactive shell and a non-interactive shell. But what exactly differentiates a login shell from a non-login shell?
Can you give examples for uses of a ...
20
votes
6answers
2k 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 ...
17
votes
7answers
5k views
Batch renaming files
I have a directory full of images:
image0001.png
image0002.png
image0003.png
...
And I would like a one-liner to rename them to (say).
0001.png
0002.png
0003.png
...
How do I do this?
13
votes
2answers
4k 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 ...
4
votes
4answers
2k views
Evolution of Operating systems from Unix
Can you explain the evolution hierarchy of operating systems (Linux and Windows) from Unix?
19
votes
4answers
3k 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...
6
votes
3answers
692 views
How to run a command when a directory's contents are updated?
There is a directory A whose contents are changed frequently by other people.
I have made a personal directory B where I keep all the files that have ever been in A.
Currently I just occasionally ...
226
votes
7answers
20k views
Understanding the Linux kernel source
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 ...
46
votes
2answers
17k 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 ...
21
votes
2answers
866 views
Can a bash script be hooked to a file?
I want a script to sleep unless a certain file is modifed/deleted (or a file created in a certain directory, or ...). Can this be achieved in some elegant way? The simplest thing that comes to my mind ...
