155 Answered Questions for the topic Linux
05/06/19
Argument list too long error for rm, cp, mv commands?
I have several hundred PDFs under a directory in UNIX. The names of the PDFs are really long (approx. 60 chars).
When I try to delete all PDFs together using the following command:
rm -f...
more
How do I write stderr to a file while using "tee" with a pipe?
I know how to use `tee` to write the output (`STDOUT`) of `aaa.sh` to `bbb.out`, while still displaying it in the terminal:
./aaa.sh | tee bbb.out
How would I now also write `STDERR` to a file...
more
Getting root permissions on a file inside of vi?
Often while editing config files, I'll open one with vi and then when I go to save it realize that I didn't type
sudo vi filename
Is there any way to give vi sudo privileges to save the file? I...
more
How to kill all processes with a given partial name?
I want to kill all processes that I get by:
ps aux | grep my_pattern
How to do it?
This does not work:
pkill my_pattern
05/04/19
open() in Python does not create a file if it doesn't exist?
What is the best way to open a file as read/write if it exists, or if it does not, then create it and open it as read/write? From what I read, `file = open('myfile.dat', 'rw')` should do this,...
more
How do I know the script file name in a Bash script?
How can I determine the name of the Bash script file inside the script itself?
Like if my script is in file `runme.sh`, then how would I make it to display "You are running runme.sh" message...
more
Aborting a shell script if any command returns a non-zero value?
I have a Bash shell script that invokes a number of commands.
I would like to have the shell script automatically exit with a return value of 1 if any of the commands return a non-zero value.
Is...
more
05/03/19
OneNote alternative for Windows, Linux, and Android?
I’m looking for an alternative to Microsoft OneNote. I usually use OneNote to sync my notes between my Windows 8 computer and my Android phone, but I’ve been using Linux (Ubuntu 14.04) quite often...
more
How to 'grep' a continuous stream?
Is that possible to use `grep` on a continuous stream?
What I mean is sort of a `tail -f <file>` command, but with `grep` on the output in order to keep only the lines that interest...
more
How can I copy the output of a command directly into my clipboard?
How can I pipe the output of a command into my clipboard and paste it back when using a terminal? For instance:
cat file | clipboard
04/28/19
Is there a program to control other computers from another computer?
Is there a good **remote desktop software tool** that I can use to control my Windows and Linux PCs from my Mac, and vice-versa?
I don't care if it uses up lots of internet bandwidth.
Desired...
more
Delete empty lines using sed?
I am trying to delete empty lines using sed:
sed '/^$/d'
but I have no luck with it.
For example, I have these lines:
xxxxxx
yyyyyy
zzzzzz
and I want it to be like:
xxxxxx
...
more
04/28/19
How to get the current date and time in the terminal and set a custom command in terminal for it?
I have to check the time in linux terminal.<br/>
What is the command for getting date and time in Linux terminal ?<br/>
Is there any way in which we can set custom function ?
Git keeps asking me for my ssh key passphrase?
I'm using Linux and I created keys as instructed in the github tutorial, registered them with github, and tried using ssh-agent explicitly — yet git continues to ask me for my passphrase every time...
more
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...
more
04/26/19
What is ":-!!" in C code?
I bumped into this strange macro code in [/usr/include/linux/kernel.h][1]:
/* Force a compilation error if condition is true, but also produce a
result (of value 0 and type size_t), so the...
more
04/26/19
Why does the C preprocessor interpret the word "linux" as the constant "1"?
Why does the C preprocessor in GCC interpret the word `linux` (small letters) as the constant `1`?test.c: #include <stdio.h> int main(void) { int linux = 5; ...
more
Recursively look for files with a specific extension?
I'm trying to find all files with a specific extension in a directory and its subdirectories with my bash (Latest Ubuntu LTS Release).
This is what's written in a script file:
#!/bin/bash
...
more
How does "cat << EOF" work in bash?
I needed to write a script to enter multi-line input to a program (`psql`).
After a bit of googling, I found the following syntax works:
cat << EOF | psql ---params
BEGIN;
`pg_dump...
more
Linux Symlink
04/22/19
How to symlink a file in Linux?
I want to make a symbolic link in Linux. I have written this bash command where the first path is the folder I want link into and the second path is the compiled source.
ln -s...
more
Linux Microsoft Word
04/20/19
Markdown to Word/PDF converter for Linux?
Does anyone know of a good Markdown to Word Converter? It would be great if it also converts to PDF.
04/20/19
Need a good hex editor for Linux?
I need a good HEX editor for Linux, and by good I mean:
* Fast
* Search/replace features
* Can display data not only in hex, but also binary, octal, etc.
* Can work with huge (> 1 gb) files...
more
How to get full path of a file?
Is there an easy way I can print the full path of `file.txt` ?
file.txt = /nfs/an/disks/jj/home/dir/file.txt
The `<command>`
dir> <command> file.txt
should print
...
more
04/20/19
Note-taking application that can sync between Windows, Ubuntu and Android?
Evernote has been one of the most used note-taking application for me, with it syncing between my Windows PC and my Android device. I usually use the Evernote desktop client on my Windows PC and...
more
Restarting cron after changing crontab file?
Do I have to restart cron after changing the crontable file?
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.