The command-line is the interactive interface to your shell.

learn more… | top users | synonyms (1)

67
votes
12answers
84k views

Efficiently delete large directory containing thousands of files

We have an issue with a folder becoming unwieldy with hundreds of thousands of tiny files. There are so many files that performing rm -rf returns an error and instead what we need to do is something ...
2
votes
0answers
191 views

How do I recursively apply default ACLs of a directory to its descendants?

If I have a directory with default ACL entries assigned to it, but some or all of its descendant files and sub-directories have access or default ACLs that do not agree with those defaults, how do I ...
0
votes
2answers
35 views

Uuencode is displaying the file contents in email body instead of attaching the file in the attachments

I want to send a simple text file as an attachment in an email. When the email is delivered, the attachment is missing, instead, the contents of the attachments are displayed in the email body. Need ...
4
votes
2answers
71 views

Why does path-completion in bash not always work?

With different bash-environments (different installations) I have different behaviors in terms of path-completion when hitting TAB on the command line after . Where is this handled? One specific ...
6
votes
1answer
46 views

Display stdout and stderr in two separate streams

I'm looking for a way to visually separate stdout and stderr, so that they don't interleave and so that they can be easily identified. Ideally, stdout and stderr would have separate areas on the ...
3
votes
2answers
31 views

Forward results of Find command to javac

I wish to compile the results of a find command where the find command returns the relative filepath of a java file located in subdirectories. E.G., I am in ./ and I want to run javac on a file, ...
2
votes
3answers
467 views

Pass output of “whereis” command to “cd” to change directory in one step

It should be simple no-doubt, but I can't find a way to pass output of whereis command to cd command in same line so I don't have to do cd in the second step. I have tried passing like below: cd $(...
7
votes
1answer
840 views

shebang line not working with cr-lf

Why are the shebang parts of the following elementary scripts not working: $ cat hello.sh #! /bin/sh echo Hello $ ./hello.sh bash: ./hello.sh: /bin/sh^M: bad interpreter: No such file or directory $ ...
0
votes
4answers
55 views

Delete specific line numbers (passed as variable) from a file in linux

I have two files. One having list of lines (which I don't require) say Seqlist and other text file (from which I intend to delete those corresponding lines) say ContentFile $cat Seqlist 3 4 ...
2
votes
1answer
54 views

Submit password with sudo and execute script with nohup

I would like to download and run a script in the background so the task is independent of the shell and its exit. Moreover this script should be run as sudo, using: echo MY_PWD | sudo -u MY_USER -S .....
-3
votes
0answers
37 views

I want something to be printed at the start and end of dmesgs [closed]

echo " END COLLECTING DMESG_">/dev/kmsg is the command I used before running an IO and after running an IO. Once after clearing dmesg, sometimes I was unable to print the statement.
1
vote
1answer
24 views

Use SELinux to restrict a directory to a particular user

I have a couple of questions: (Sysadmins tasks) Here is what I asked to do Create user Tim and add him to the supplementary group Webdev (Create the group if it doesn't exist), also Set Tim's ...
3
votes
1answer
2k views

How to access u boot environment from linux?

How can I access and change the u-Boot env variables in linux. Using the u-boot/tools/env directory in u boot directory: u-boot$ make env Which created the executable file fw_printenv. I copied ...
1
vote
0answers
22 views

open several directories from the terminal as tabs inside a single file manager window

I want to open several directories from the terminal as tabs inside a single Nautilus window. If Nautilus cannot be used then I want to know what GUI based file explorer can open directories in ...
57
votes
13answers
130k views

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?
11
votes
5answers
9k views

How to randomly sample a subset of a file

Is there any Linux command one can use to sample subset of a file? For instance, a file contains one million lines, and we want to randomly sample only one thousand lines from that file. For random ...
68
votes
10answers
47k views

How can I move files and view the progress (e.g. with a progress bar)?

When moving large directories using mv, is there a way to view the progress (%)? The cp command on gentoo had a -g switch that showed the progress.
-1
votes
1answer
43 views

Curl to grab the page after complete load

I have a url which takes some time to load completely. But when I use curl to download the link as html, it download the html at the real time before loading page completely I mean complete execution ...
0
votes
1answer
48 views

Unix, create file based on command [duplicate]

I have a command, but I want to get the results into a .txt file I can open. How do I alter my command to allow the results to be put into a text file. I plan to transfer this .txt file to my local ...
1
vote
2answers
61 views

How to zip directory with encryption for file names?

Using command line, I know that I can encrypt a directory with the following command: zip -er Directory.zip /path/to/directory However, this does not encrypt the filenames themselves. If someone ...
1
vote
2answers
45 views

How to move string from one line to another

I have been editing a large text file containing pairs of lines as follows (repeated): \> destination_file.txt js -e "var e='.jpg',t='b',i='14712583',h='0.us.is.example.com',s='/',n='WIV',u='...
-1
votes
0answers
36 views

dd does not work for an image created in freebsd 9.3

I tried to dd the image created in freebsd 9.3 $ sudo dd if=test.img of=/dev/disk2 bs=1m Password: 0+0 records in 0+0 records out 0 bytes transferred in 0.000010 secs (0 bytes/sec) This works in ...
11
votes
6answers
19k views

How to remove blank lines from a file in shell?

I want to remove all empty lines from a file. Even if the line contains spaces or tabs it should also be removed.
8
votes
3answers
5k views

How do I permanently change the console TTY font type so it holds after reboot?

I'm running Ubuntu 15.04 64-bit Desktop Edition (A Debian based Linux). I used sudo dpkg-reconfigure console-setup from the command line to change the default console font type to Terminus. ...
5
votes
1answer
65 views

Random image generator

I am generating random data and trying to convert it to a PNG image using : head -c 1MB < /dev/urandom | hexdump -e '16/1 "_x%02X"' | sed 's/_/\\/g; s/\\x //g; s/.*/ "&"/' | tr -d "\"" | ...
3
votes
2answers
2k views

Getting a list of WiFi networks nearby when the adapter is in AP mode

I am trying to get a list of wireless networks nearby while the adapter is acting as an access point but iwlist returns the following error: $ sudo iwlist wlan0 scan wlan0 Interface doesn't ...
9
votes
11answers
10k views

linux diff tools: create list of modified files

How do I create a list of modified files programmatically using linux command line tools? I'm not interested in the difference in any particular file (delta, patch). I just want to have a list of new ...
58
votes
5answers
37k views

How to redirect output of wget as input to unzip?

I have to download a file from this link. The file download is a zip file which I will have to unzip in the current folder. Normally, I would download it first, then run the unzip command. $ wget ...
0
votes
0answers
16 views

steps to troubleshoot bluetooth dongle?

How do I troubleshoot, or at least gather more data in order to troubleshoot, a bluetooth dongle? In particular, from the CLI. On a lower level, I can see the bluetooth hardware: thufir@mordor:~$ ...
32
votes
2answers
1k views

Difference between “command not found” and “no such file or directory”?

For example: $ node -bash: /usr/local/bin/node: No such file or directory $ foo -bash: foo: command not found What's the difference? In both cases, node and foo are invalid commands, but it seems ...
0
votes
1answer
32 views

Cleanest way to require the user to enter password to run a program?

What is the cleanest way to require the user to enter password in order to run a particular program without the use of third-party applications? For example, if I type firefox to launch it from the ...
1
vote
1answer
24 views

How do I select which remote vifm instance will run a command?

I run two separate instances of vifm on my machine: $ vifm --server-list documents photos In one I'm organising documents and in the other photos. Sometimes I'm inside a third shell and would like ...
0
votes
0answers
7 views

Why doesn't wpa_supplicant work when using crontab job?

I am writing a script that is installed via a crontab job. The point of the script is to locate a specific AP and connect to it on start up. The script will log its progress to a text file called, "...
0
votes
1answer
109 views

How to set torify + whois work correctly?

i'm using manjaro. I'm trying to use: torify whois, torsocks whois, proxychais whois. I tried to do that with sudo command, and all this command give me back the same output: [Feb 23 21:15:57] PERROR ...
0
votes
2answers
79 views

how to exclude string that include space by “grep -v” [closed]

I have a script that runs by using bash -c and I want to know how many process are running with that script. $ ps ax | grep my_script_run | grep -v grep | grep -v "bash -c" 11121 ? S 0:00 ...
239
votes
24answers
184k views

Repeat a Unix command every x seconds forever

There's a built-in Unix command repeat whose first argument is the number of times to repeat a command, where the command (with any arguments) is specified by the remaining arguments to repeat. For ...
-2
votes
2answers
62 views

Find all line in a file which start with g or any digit from 0to9

How do I find all lines in a file which start with g or any digit from 0 to 9? Can any one help me using command line? I try and I know how to do if start with g but don't know how to do with g and 0 ...
11
votes
8answers
2k views

Move first N lines of output to end without using temporary file

Imagine an output of a command like 44444 55555 11111 22222 33333 how can I yank the first N lines (first two in the example above) and append them at the end, but without using temp file (so only ...
-1
votes
3answers
42 views

Run su -s with arguments

I run to run a command using the su -s command to start a process. Since I do not want the root user to own the process. I try to do this by issuing the command su -s "$CATALINA_HOME/bin/catalina.sh ...
1
vote
0answers
36 views

Converting .odm to .odt or .pdf - command line

I saw this question: Converting .odm to .odt, where someone shows to convert an .odm file into .odt or .pdf. Is there also a way to do this in a command line? I have an Open Document Master file, ...
0
votes
1answer
43 views

what is difference between l and ls commands [duplicate]

ls command shows the following : a code controller.js mani sparat this ubuntu.gif l command the shows similar to that : a/ code/ controller.js mani/ sparat/ this/ ubuntu.gif What is ...
2
votes
3answers
54 views

How to delete a variable string in file

Actually I am using sed -e s/Perro-A//g -i *-a.log to delete the string Perro-A from many files ending with *-a.log. But sometimes in the files I might not have Perro-A; I might have strings ...
4
votes
3answers
36 views

Confirm “svn ci” command depending on my current location

I am working in a big project using SVN and many times I have to go see things in other people's branches and play with them. But I want to keep those changes local, never commit them. By mistake, ...
3
votes
2answers
27 views

Start command and provide prompt parameter

I have a command that builds things and then provides an interactive shell through prompt (eg type R to restart, Q to quit, ...). I would like to use that command but stop it once it reaches the ...
2
votes
1answer
37 views

GNU screen tab gets renamed whenever I type a command

When I use gnu screen, in other tabs, I ssh into other machines, rename the tab accordingly, and do work normally. The tab name sticks. In a fresh tab, which is just a terminal on the original ...
1
vote
0answers
27 views

Find recursively files that have a percentage of lines in common

Is possible to do this? I want an output where i have only files that are 50% the same of others or have 20+ lines in commons. I'm trying to isolate commons functions in *.java files. Thank you!
80
votes
8answers
117k views

ssh-add complains: Could not open a connection to your authentication agent

I've been trying to get ssh-add working on a RaspberryPi running Raspbian. I can start ssh-agent, when I do it gives the following output into the terminal: SSH_AUTH_SOCK=/tmp/ssh-06TcpPflMg58/...
0
votes
2answers
41 views

Is there a way to use this command without having to type 'y' all the time?

I am trying to remove all ruby gems before uninstalling ruby. The command I am using is: sudo gem uninstall --all to achieve this. However, I have to type y continually to remove things. Is ...
3
votes
1answer
59 views

Removing file and its sym links

If I create a file and symlink to it e.g touch "example" ln -s "example" "link_example" and use rm example the symlink is still there. How can I delete file and all symlinks that points to that ...