Most Popular
1500 questions
363
votes
5 answers
How do I set an environment variable on the command line and have it appear in commands?
If I run
export TEST=foo
echo $TEST
It outputs foo.
If I run
TEST=foo echo $TEST
It does not. How can I get this functionality without using export or a script?
ashleysmithgpu
- 4,287
- 3
- 21
- 19
361
votes
11 answers
How can I monitor disk io?
I'd like to do some general disk io monitoring on a debian linux server. What are the tools I should know about that monitor disk io so I can see if a disk's performance is maxed out or spikes at certain time throughout the day?
camomileCase
- 3,835
- 3
- 14
- 7
361
votes
18 answers
How do I set my DNS when resolv.conf is being overwritten?
Most of the info I see online says to edit /etc/resolv.conf, but any changes I make there just get overridden.
$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND…
Seán Hayes
- 4,511
- 4
- 15
- 11
361
votes
21 answers
How do I trim leading and trailing whitespace from each line of some output?
I would like to remove all leading and trailing spaces and tabs from each line in an output.
Is there a simple tool like trim I could pipe my output into?
Example file:
test space at back
test space at front
TAB at end
TAB at front
sequence…
rubo77
- 27,777
- 43
- 130
- 199
359
votes
5 answers
How to set default file permissions for all folders/files in a directory?
I want to set a folder such that anything created within it (directories, files) inherit default permissions and group.
Lets call the group "media". And also, the folders/files created within the directory should have g+rw automatically.
Chris
- 8,320
- 5
- 23
- 18
358
votes
4 answers
How do I clear Bash's cache of paths to executables?
When I execute a program without specifying the full path to the executable, and Bash must search the directories in $PATH to find the binary, it seems that Bash remembers the path in some sort of cache. For example, I installed a build of…
Daniel Trebbien
- 3,805
- 2
- 15
- 9
358
votes
11 answers
Prepending a timestamp to each line of output from a command
I wish to prepend a timestamp to each line of output from a command. For example:
foo
bar
baz
would become
[2011-12-13 12:20:38] foo
[2011-12-13 12:21:32] bar
[2011-12-13 12:22:20] baz
...where the time being prefixed is the time at which the line…
anon
355
votes
6 answers
How to define 'tab' delimiter with 'cut' in Bash?
Here is an example of using cut to break input into fields using a space delimiter, and obtaining the second field:
cut -f2 -d' '
How can the delimiter be defined as a tab, instead of a space?
Muhammad Hasan Khan
- 3,653
- 2
- 14
- 6
355
votes
3 answers
Hide curl output
I'm making a curl request where it displays an html output in the console like this
Warning: Cannot modify header information - headers already sent by (output started at…
Rjack
- 3,553
- 2
- 11
- 4
347
votes
5 answers
How can I update to a newer version of Git using apt-get?
I've just set up a new machine with Ubuntu Oneiric 11.10 and then run
apt-get update
apt-get upgrade
apt-get install git
Now if I run git --version it tells me I have git version 1.7.5.4 but on my local machine I have the much newer git version…
cwd
- 44,479
- 71
- 146
- 167
346
votes
10 answers
Change the Python3 default version in Ubuntu
I am using Ubuntu 16.04 LTS . I have python3 installed. There are two versions installed, python 3.4.3 and python 3.6 . Whenever I use python3 command, it takes python 3.4.3 by default. I want to use python 3.6 with python3.
python3 --version shows…
codeclue
- 3,573
- 3
- 9
- 6
345
votes
21 answers
How can I run ssh-add automatically, without a password prompt?
I want to communicate between several computers on my network (static Ethernet), through SSH. In order to do that I need to run ssh-add every time I log in on a specific machine.
What can I do so it's set up once and it doesn't ask me for the…
zdun8
- 3,617
- 4
- 13
- 8
345
votes
4 answers
What does "rc" in .bashrc stand for?
Is it "resource configuration", by any chance?
Lazer
- 34,477
- 25
- 70
- 75
345
votes
20 answers
How can I get a count of files in a directory using the command line?
I have a directory with a large number of files. I don't see a ls switch to provide the count. Is there some command line magic to get a count of files?
Blake
- 3,637
- 2
- 16
- 8
344
votes
4 answers
How to permanently set environmental variables
My variables are
LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
ORACLE_HOME=/usr/lib/oracle/11.2/client64
How to save these variables permanently ?
user3021349
- 15,909
- 8
- 19
- 21