Most Popular
1500 questions
552
votes
7 answers
How do I check package version using apt-get / aptitude?
Before I install a package, I'd like to know what version I would get.
How do I check the version before installing using apt-get or aptitude on Debian or Ubuntu?
user4069
543
votes
12 answers
How do I copy a folder keeping owners and permissions intact?
So I was going to back up my home folder by copying it to an external drive as follows:
sudo cp -r /home/my_home /media/backup/my_home
With the result that all folders on the external drives are now owned by root:root. How can I have cp keep the…
Psachnodaimonia
- 5,555
- 3
- 14
- 8
543
votes
7 answers
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 non-login interactive shell?
Igorio
- 7,279
- 7
- 20
- 11
542
votes
7 answers
Can I zip an entire folder using gzip?
I'm trying to zip a folder in unix.
Can that be done using the gzip command?
user1269502
- 5,521
- 4
- 13
- 4
541
votes
4 answers
recursive mkdir
Is there a linux command that I'm overlooking that makes it possible to do something along the lines of:
(pseudo)
$ mkdir -R foo/bar/zoo/andsoforth
Or is there no alternative but to make the directories one at a time?
Dr.Dredel
539
votes
13 answers
How to forward X over SSH to run graphics applications remotely?
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 LAN.
I know that the -X option enables X11…
Mr. Shickadance
- 6,884
- 6
- 26
- 28
538
votes
10 answers
How to conditionally do something if a command succeeded or failed
How can I do something like this in bash?
if "`command` returns any error";
then
echo "Returned an error"
else
echo "Proceed..."
fi
Shinmaru
534
votes
7 answers
What is the difference between the Bash operators [[ vs [ vs ( vs ((?
I am a little bit confused on what do these operators do differently when used in bash (brackets, double brackets, parenthesis and double parenthesis).
[[ , [ , ( , ((
I have seen people use them on if statements like this :
if [[condition]]
if…
RetroCode
- 5,489
- 3
- 10
- 8
529
votes
4 answers
In a bash script, using the conditional "or" in an "if" statement
This question is a sequel of sorts to my earlier question. The users on this site kindly helped me determine how to write a bash for loop that iterates over string values. For example, suppose that a loop control variable fname iterates over the…
Andrew
- 16,315
- 34
- 73
- 77
529
votes
8 answers
How can I pass a command line argument into a shell script?
I know that shell scripts just run commands as if they were executed in at the command prompt. I'd like to be able to run shell scripts as if they were functions... That is, taking an input value or string into the script. How do I approach doing…
Paul
- 9,163
- 12
- 32
- 30
523
votes
15 answers
Turn off buffering in pipe
I have a script which calls two commands:
long_running_command | print_progress
The long_running_command prints progress but I'm unhappy with it. I'm using print_progress to make it nicer (namely, I print the progress in a single line).
The…
Aaron Digulla
- 5,918
- 4
- 19
- 17
513
votes
9 answers
Execute vs Read bit. How do directory permissions in Linux work?
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, and how do directory permissions in Linux work?
Nick.h
- 6,193
- 4
- 20
- 16
505
votes
6 answers
How to copy a file from a remote server to a local machine?
In my terminal shell, I ssh'ed into a remote server, and I cd to the directory I want.
Now in this directory, there is a file called table that I want to copy to my local machine /home/me/Desktop.
How can I do this?
I tried scp table…
omega
- 5,537
- 5
- 18
- 14
502
votes
14 answers
How do I loop through only directories in bash?
I have a folder with some directories and some files (some are hidden, beginning with dot).
for d in *; do
echo $d
done
will loop through all files and directories, but I want to loop only through directories. How do I do that?
rubo77
- 27,777
- 43
- 130
- 199
490
votes
13 answers
How do I remove a user from a group?
Which command should I use to remove a user from a group in Debian?
When adding a user to a group, it can be done with:
usermod -a -G group user
However, I could not find a similar command (accepting a group and user as arguments) for removing the…
Lekensteyn
- 20,173
- 18
- 71
- 111