Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hello,
i have 2 questions .. i've seen that for bringing a program to the foreground, one should write simply fg 1 (1 is the number of the job) ... but for sending a job to the background, one should write fg %1 .. why ? what does % means here?
my second questions, is what does & mean, when you write: 1>&2 (I'm trying that the stdout and sterr go to the same place) ...
when i want the stdout to go to a file, a simply write 1> file , the same with the stderr, so what does it mean the & here? (1>%2) ?
To send a program to the background you can run the program followed by an apersand. Such as: "./configure &" to run the process in the background while you attend to other tasks.
The question about foreground/background.
A program can be suspended using ctrl+z
To take up execution in foreground type fg %1
To take up the execution in the background use bg %1
To the redirection question.
Both 1>&2 and 2>&1
The numbers are called file handles.
File handle 0 is standard input(stdin), 1 is standard output(stdout) and 2 is standard error(stderr).
The redirection above says redirect stdout to file handle stderr. The & sign need to be there much like the $-sign in variables references in shell script.
Good question. I don't have good explanation right now, but if I come across an answer I'll post it.
Both 1>&2 and 2>&1 work but they do different things
First directs all output to where stderr ends up, which might be the system log.
The other one makes the errors end up where stdout does, normally the screen.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.