Most Popular
1500 questions
118
votes
11 answers
Why does argv include the program name?
Typical Unix/Linux programs accept the command line inputs as an argument count (int argc) and an argument vector (char *argv[]). The first element of argv is the program name - followed by the actual arguments.
Why is the program name passed to…
Shrikant Giridhar
- 1,267
- 2
- 11
- 13
118
votes
2 answers
ulimit: difference between hard and soft limits
What is the difference between hard and soft limits in ulimit?
For number of open files, I have a soft limit of 1024 and a hard limit of 10240.
It is possible to run programs opening more than 1024 files. What is the soft limit for?
daniel kullmann
- 9,427
- 11
- 38
- 45
118
votes
10 answers
Is it possible to run ssh-copy-id on port other than 22?
I have a server with SSH running on a non-standard port. Instead of 22, it runs on 8129. To log in, I use:
ssh -p 8129 hostname
Now, whenever I need to set up a key for password-less login, I have to copy the public key and add it to…
Milan Babuškov
- 2,182
- 4
- 17
- 13
118
votes
20 answers
What is the fastest way to send massive amounts of data between two computers?
This is a situation I am frequently in:
I have a source server with a 320GB hard-drive inside of it, and 16GB of ram (exact specs available here, but as this is an issue I run into frequently on other machines as well, I would prefer the answer to…
IQAndreas
- 10,145
- 21
- 59
- 79
118
votes
11 answers
Bash history: "ignoredups" and "erasedups" setting conflict with common history across sessions
First of all, this is not a duplicate of any existing threads on SE. I have read these two threads (1st, 2nd) on better bash history, but none of the answers work - - I am on Fedora 15 by the way.
I added the following to the .bashrc file in the…
its_me
- 13,709
- 23
- 54
- 52
118
votes
2 answers
Setting /proc/sys/vm/drop_caches to clear cache
As part of doing some cold cache timings, I'm trying to free the OS cache. The kernel documentation (retrieved January 2019) says:
drop_caches
Writing to this will cause the kernel to drop clean caches, as well as
reclaimable slab objects like…
Faheem Mitha
- 34,649
- 32
- 119
- 183
118
votes
4 answers
Writing basic systemd service files
I am developing a Nodejs application that the user interacts with via HTTP on localhost. There are practically no parameters and the daemon has virtually no dependencies and it just needs to be up by log-in time.
I would like to follow the idioms on…
beatgammit
- 7,453
- 10
- 31
- 32
118
votes
6 answers
Replace multiple spaces with one using 'tr' only
I have a file, f1.txt:
ID Name
1 a
2 b
3 g
6 f
The number of spaces is not fixed. What is the best way to replace all the white spaces with one space using only tr?
This is what I have so far:
cat f1.txt | tr -d "…
gkmohit
- 3,219
- 8
- 27
- 30
118
votes
6 answers
is my linux ARM 32 or 64 bit?
under an intel I know I can look at the outcome of uname -m to know if my OS is 32 or 64 bit, but under ARM this gives:
armv7l
I deduced from
file /usr/bin/ls
that I'm on a 32-bit OS, but how can I know this in an easier way?
Chris Maes
- 3,282
- 3
- 21
- 32
118
votes
10 answers
Harddisk serial number from terminal?
I have multiple hard disks which get connected to my server and I'm not sure which one is what in the view of sdXY. If I could see the serial numbers of my hard disks from terminal, I could easily identify them.
Is there any way I can get the serial…
Raja G
- 5,749
- 12
- 44
- 67
117
votes
14 answers
How can I search history with text already entered at the prompt in zsh?
In zsh, I know that I can search history with Ctrl+r. However, oftentimes I start to type a command directly at the prompt, but then realize I should be searching history. When I hit Ctrl+r, it brings up a blank history search prompt like…
Sean Mackesey
- 1,547
- 2
- 10
- 14
117
votes
5 answers
Determining what process is bound to a port
I know that using the command:
lsof -i TCP
(or some variant of parameters with lsof) I can determine which process is bound to a particular port. This is useful say if I'm trying to start something that wants to bind to 8080 and some else is…
user5721
117
votes
7 answers
rsync compare directories?
Is it possible to compare two directories with rsync and only print the differences? There's a dry-run option, but when I increase verbosity to a certain level, every file compared is shown.
ls -alR and diff is no option here, since there are…
chris
- 1,635
- 2
- 16
- 19
117
votes
7 answers
Flattening a nested directory
This is probably very simple, but I can't figure it out. I have a directory structure like this (dir2 is inside dir1):
/dir1
/dir2
|
--- file1
|
--- file2
What is the best way to 'flatten' this directory structure…
turtle
- 2,607
- 5
- 19
- 16
117
votes
16 answers
How to determine the path to a sourced tcsh or bash shell script from within the script
Is there a way for a sourced shell script to find the path to itself? I'm mainly concerned with bash, though I have some coworkers who use tcsh.
I'm guessing I may not have much luck here since sourcing causes commands to be executed in the current…
Cascabel
- 1,611
- 2
- 12
- 15