Most Popular
1500 questions
123
votes
5 answers
How to dd a remote disk using SSH on local machine and save to a local disk
How can I create a backup of a remote disk using SSH on my local machine and save it to a local disk?
I've tried the following:
ssh [email protected] "sudo dd if=/dev/sdX " | \
dd of=/home/username/Documents/filename.image`
However, I…
Qu0rk
- 1,371
- 2
- 10
- 9
123
votes
6 answers
How to run a command that involves redirecting or piping with sudo?
I am trying to follow what I assume is best practices of using sudo instead of root account.
I am running a simple concat file operation such as:
sudo echo 'clock_hctosys="YES"' >> /etc/conf.d/hwclock
This fails as to the right of the ">>" it is…
DarkSheep
- 1,796
- 3
- 14
- 18
123
votes
2 answers
`find` with multiple `-name` and `-exec` executes only the last matches of `-name`
When I'm using
find . -type f -name "*.htm*" -o -name "*.js*" -o -name "*.txt"
it finds all the types of file. But when I add -exec at the end:
find . -type f -name "*.htm*" -o -name "*.js*" -o -name "*.txt" -exec sh -c 'echo "$0"' {} \;
it seems…
jakub.g
- 3,153
- 5
- 20
- 17
122
votes
3 answers
Why is swappiness set to 60 by default?
I just read some stuff about swappiness on Linux. I don't understand why the default is set to 60.
According to me this parameter should be set to 10 in order to reduce swap. Swap is on my hard drives so it us much slower than my memory.
Why did…
Hugo
- 2,419
- 7
- 27
- 32
122
votes
12 answers
Sorting files according to size recursively
I need to find the largest files in a folder.
How do I scan a folder recursively and sort the contents by size?
I have tried using ls -R -S, but this lists the directories as well.
I also tried using find.
user2179293
- 1,753
- 5
- 15
- 15
122
votes
13 answers
Show sum of file sizes in directory listing
The Windows dir directory listing command has a line at the end showing the total amount of space taken up by the files listed. For example, dir *.exe shows all the .exe files in the current directory, their sizes, and the sum total of their sizes.…
MattDMo
- 2,314
- 3
- 19
- 28
122
votes
3 answers
su vs sudo -s vs sudo -i vs sudo bash
What is the difference between the following commands:
su
sudo -s
sudo -i
sudo bash
I know for su I need to know the root password, and for sudo I have to be in the sudoers file, but once executed what is difference?
I know there is a difference…
TJ Shah
- 1,711
- 3
- 13
- 13
122
votes
7 answers
Grabbing the first [x] characters for a string from a pipe
If I have really long output from a command (single line) but I know I only want the first [x] (let's say 8) characters of the output, what's the easiest way to get that? There aren't any delimiters.
xenoterracide
- 57,918
- 74
- 184
- 250
122
votes
8 answers
Disable a user's login without disabling the account
Let's say I create a user named "bogus" using the adduser command. How can I make sure this user will NOT be a viable login option, without disabling the account. In short, I want the account to be accessible via su - bogus, but I do not want it to…
Malabarba
- 2,009
- 3
- 15
- 14
122
votes
3 answers
How can I assign the output of a command to a shell variable?
I want to assign the result of an expression
(i.e., the output from a command)
to a variable and then manipulate it – for example,
concatenate it with a string, then echo it.
Here's what I've got:
#!/bin/bash
cd ~/Desktop;
thefile= ls -t -U | grep…
Nathan G.
- 1,368
- 2
- 9
- 8
122
votes
3 answers
Why is "echo" so much faster than "touch"?
I'm trying to update the timestamp to the current time on all of the xml files in my directory (recursively). I'm using Mac OSX 10.8.5.
On about 300,000 files, the following echo command takes 10 seconds:
for file in `find . -name "*.xml"`; do echo…
Casey Patton
122
votes
6 answers
What is the difference between 'env' and 'printenv'?
What is the difference between the two commands env and printenv? They both show the environment variables, and the output is exactly the same aside from _.
Are there any historical reasons for there being two commands instead of one?
WiSaGaN
- 1,383
- 2
- 8
- 10
121
votes
7 answers
Create a tar archive split into blocks of a maximum size
I need to backup a fairly large directory, but I am limited by the size of individual files. I'd like to essentially create a tar.(gz|bz2) archive which is split into 200MB maximum archives. Clonezilla does something similar to this by splitting…
Naftuli Kay
- 38,686
- 85
- 220
- 311
121
votes
10 answers
Vi vs vim, or, is there any reason why I would ever want to use vi?
I know a bit about *NIX text editors (currently migrating from nano to vim), and, after looking around a bit on the Unix & Linux SE, have noticed that vi is used instead of 'vim' in a fair number of questions. I know that 'vim' stands for 'Vi…
fouric
- 2,261
- 4
- 22
- 25
121
votes
6 answers
What's the best way to join files again after splitting them?
If I have a large file and need to split it into 100 megabyte chunks I will do
split -b 100m myImage.iso
That usually give me something like
xaa
xab
xac
xad
And to get them back together I have been using
cat x* > myImage.iso
Seems like there…
cwd
- 44,479
- 71
- 146
- 167