227,598 questions
423
votes
21
answers
397k
views
Is there a way to make mv create the directory to be moved to if it doesn't exist?
So, if I'm in my home directory and I want to move foo.c to ~/bar/baz/foo.c , but those directories don't exist, is there some way to have those directories automatically created, so that you would ...
411
votes
8
answers
620k
views
How can I remove specific rules from iptables? [closed]
I am hosting special HTTP and HTTPS services on the ports 8006 and 8007 respectively. I use iptables to "activate" the server; i.e. to route the incoming HTTP and HTTPS ports:
iptables -A INPUT -i ...
410
votes
3
answers
803k
views
How to change the default shell in Linux? [closed]
How is it possible to change the default shell? The env command currently says:
SHELL=/bin/tcsh
and I want to change that to Bash.
403
votes
8
answers
366k
views
How can I get the start time of a long-running Linux process?
Is it possible to get the start time of an old running process? It seems that ps will report the date (not the time) if it wasn't started today, and only the year if it wasn't started this year. Is ...
400
votes
9
answers
424k
views
How to use `subprocess` command with pipes
I want to use subprocess.check_output() with ps -A | grep 'process_name'.
I tried various solutions but so far nothing worked. Can someone guide me how to do it?
396
votes
31
answers
1.6m
views
sudo: npm: command not found
I'm trying to upgrade to the latest version of node. I'm following the instructions at http://davidwalsh.name/upgrade-nodejs
But when I do:
sudo npm install -g n
I get the error:
sudo: npm: command ...
395
votes
5
answers
266k
views
Difference between shared objects (.so), static libraries (.a), and DLL's (.so)?
I have been involved in some debate with respect to libraries in Linux, and would like to confirm some things.
It is to my understanding (please correct me if I am wrong and I will edit my post later),...
392
votes
22
answers
478k
views
Where can I set environment variables that crontab will use?
I have a crontab running every hour. The user running it has environment variabless in the .bash_profile that work when the user runs the job from the terminal, however, obviously these don't get ...
388
votes
10
answers
435k
views
How to only get file name with Linux 'find'?
I'm using find to all files in directory, so I get a list of paths. However, I need only file names. i.e. I get ./dir1/dir2/file.txt and I want to get file.txt
387
votes
2
answers
206k
views
How to suppress binary file matching results in grep [closed]
When using grep in Linux, the result often contains a lot of "binary file XXX matches", which I do not care about. How to suppress this part of the results, or how to exclude binary files in ...
378
votes
22
answers
1.7m
views
Error: Could not find or load main class [duplicate]
I am having trouble compiling and running my Java code, intended to allow me to interface Java with a shared object for Vensim, a simulation modeling package.
The following code compiles without ...
374
votes
10
answers
578k
views
How to search and replace using grep
I need to recursively search for a specified string within all files and subdirectories within a directory and replace this string with another string.
I know that the command to find it might look ...
372
votes
7
answers
579k
views
Find the files that have been changed in last 24 hours
E.g., a MySQL server is running on my Ubuntu machine. Some data has been changed during the last 24 hours.
What (Linux) scripts can find the files that have been changed during the last 24 hours?
...
367
votes
13
answers
556k
views
boto3 client NoRegionError: You must specify a region error only sometimes
I have a boto3 client :
boto3.client('kms')
But it happens on new machines, They open and close dynamically.
if endpoint is None:
if region_name is None:
# Raise a more ...
364
votes
7
answers
432k
views
How to list the contents of a package using YUM?
I know how to use rpm to list the contents of a package (rpm -qpil package.rpm). However, this requires knowing the location of the .rpm file on the filesystem. A more elegant solution would be to use ...
362
votes
26
answers
450k
views
How to create a CPU spike with a bash command
I want to create a near 100% load on a Linux machine. It's quad core system and I want all cores going full speed. Ideally, the CPU load would last a designated amount of time and then stop. I'm ...
362
votes
11
answers
573k
views
Execute combine multiple Linux commands in one line
I am trying to merge multiple linux commands in one line to perform deployment operation.
For example
cd /my_folder
rm *.jar
svn co path to repo
mvn compile package install
358
votes
18
answers
408k
views
Linux command to list all available commands and aliases
Is there a Linux command that will list all available commands and aliases for this terminal session?
As if you typed 'a' and pressed tab, but for every letter of the alphabet.
Or running 'alias' but ...
357
votes
19
answers
186k
views
How can I find all of the distinct file extensions in a folder hierarchy?
On a Linux machine I would like to traverse a folder hierarchy and get a list of all of the distinct file extensions within it.
What would be the best way to achieve this from a shell?
354
votes
14
answers
934k
views
How do I update a Python package?
I'm running Ubuntu 9:10 and a package called M2Crypto is installed (version is 0.19.1). I need to download, build and install the latest version of the M2Crypto package (0.20.2).
The 0.19.1 package ...
353
votes
10
answers
178k
views
Highlight text similar to grep, but don't filter out text [duplicate]
When using grep, it will highlight any text in a line with a match to your regular expression.
What if I want this behaviour, but have grep print out all lines as well? I came up empty after a quick ...
352
votes
13
answers
416k
views
Repeat command automatically in Linux [closed]
Is it possible in Linux command line to have a command repeat every n seconds?
Say, I have an import running, and I am doing
ls -l
to check if the file size is increasing. I would like to have a ...
352
votes
12
answers
538k
views
What languages are Windows, Mac OS X and Linux written in?
I was just wondering who knows what programming languages Windows, Mac OS X and Linux are made up from and what languages are used for each part of the OS (ie: Kernel, plug-in architecture, GUI ...
349
votes
11
answers
649k
views
How to run crontab job every week on Sunday
I'm trying to figure out how to run a crontab job every week on Sunday. I think the following should work, but I'm not sure if I understand correctly. Is the following correct?
5 8 * * 6
347
votes
12
answers
613k
views
How to recursively download a folder via FTP on Linux [closed]
I'm trying to ftp a folder using the command line ftp client, but so far I've only been able to use 'get' to get individual files.