Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 117516

These questions are about Linux in general -- NOT specific to a particular distribution. If the question just happens to be in a Linux environment, please specify your Linux distribution in the body of your question, but do NOT use the /linux tag.

1
vote
There are a number of things you can do to log command times, the easiest being accounting (cf. man accton), but all of them have to be turned on explicitly. If you didn't turn on accounting first th …
answered Oct 17 '17 by Satō Katsura
1
vote
Since you tagged this as linux I'll assume GNU utilities. Copy directory structure from $src to $dest: find "$src" -type d -print0 | cpio -padmv0 "$dest" Also copy a random sample of $nfile files …
answered May 31 '17 by Satō Katsura
31
votes
, you probably don't need to bother with redirections. Edit: Some quick (and completely broken) benchmarks: In a Linux console, 240x75: $ time (for i in {1..100000}; do echo $i …
answered Oct 12 '17 by Satō Katsura
8
votes
ttyS0 is the device for the first UART serial port on x86 and x86_64 architectures. If you have a PC motherboard with serial ports you'd be using a ttySn to attach a modem or a serial console. ttyUS …
answered Sep 2 '16 by Satō Katsura
3
votes
Here's a quick checklist: use TABs to indent action lines (rm, tar, g++ etc.) use $(FOO) to expand variable FOO instead of ${FOO} or $FOO add dependencies where relevant. Your Makefile should look …
answered Nov 10 '17 by Satō Katsura
2
votes
Since you tagged the question as Linux, you can use flock to put a lock on a well-known file: flock "${TMPDIR:-/tmp}"/some_name.lock /path/to/your_command -options A second instance of the command …
answered Nov 4 '17 by Satō Katsura
3
votes
One way to do it: #! /bin/sh n=$1 m=$2 # Reference: http://math.stackexchange.com/q/48080 sum=$(( (m * (m + 1) * (2 * m + 1) - (n - 1) * n * (2 * n - 1)) / 6 )) echo $sum Result: ./sum 3 7 135
answered Sep 15 '16 by Satō Katsura
3
votes
On Linux: printf -- '-get data_%d.txt\n' $(seq 1 3 100) | sftp -b - user@example.com On BSD (with no seq(1) in sight): printf -- '-get data_%d.txt\n' $(jot 100 1 100 3) | sftp -b - user@example.com …
answered Sep 8 '16 by Satō Katsura
2
votes
One way to do it: awk -F \| -v OFS=, '{ NF--; for(i = NF-2; i <= NF; i++) $i = sprintf("%07.2f", $i) } 1' filename
answered Dec 20 '16 by Satō Katsura
4
votes
With GNU find: find /some/path -type f -name '.*' -execdir sh -c 'mv -i "$0" "./${0#./.}"' {} \; With Perl rename: find /some/path -type f -name '.*' -exec prename -i -n 's!.*/\K\.!!' {} + (remo …
answered Oct 2 '17 by Satō Katsura
1
vote
Get your monitor's EDID and save it to a file. You can do that from Linux, with read-edid. Then go to Windows and get the parameters for the working mode. I no longer remember the details (I had … is important. If I recall correctly you want your preferred mode first. When you have the cooked EDID file copy it to Linux, and point xorg to it. Back when I did that I had to add an option like …
answered Sep 10 '16 by Satō Katsura
2
votes
With perl: perl -MJSON -F: -ple '@A = qw/randomId id userId dns status/; $_ = encode_json({map { shift @A => { "s" => $_ } } @F } )' input.csv
answered Mar 24 '17 by Satō Katsura
2
votes
If you absolutely must do it with sed: to add the line at the beginning of file: sed -i -e '1i\' -e 'HAVE_OPENBLAS = \\usr' ./settings.mk to add the line at the end of file: sed -i -e '$a\' -e 'H …
answered Nov 7 '17 by Satō Katsura
3
votes
With awk: awk '{ if(NF>4) for(i=5; i<=NF; i+=4) $i = "\n" $i } 1' file With sed: sed 's/ /\n/4;T;P;D' file With perl: perl -lpe '$c = 0; s/ /++$c % 4 ? " " : "\n"/goe' file Output: 1 2 4 5 6 …
answered May 25 '17 by Satō Katsura
0
votes
You're asking phpMyAdmin to connect by TCP but your database is listening to an UNIX socket. Remove the connect_type line and set host to localhost: $cfg['Servers'][$i]['host'] = 'localhost';
answered Oct 30 '17 by Satō Katsura
2
votes
You can use stat(1) to get the modified time of a file, but this is not portable. On Linux: $ stat -c %y some_file 2017-09-23 10:24:09.880806666 +0200 $ date -d @$(stat -c %Y some_file) +%d-%m-%Y 23-09-2017 On BSD: $ stat -f %Sm -t %d-%m-%Y some_file 23-09-2017 …
answered Oct 8 '17 by Satō Katsura
0
votes
From man 8 mount on Linux: If no -t option is given, or if the auto type is specified, mount will try to guess the desired type. Mount uses the blkid library for guessing the …
answered Oct 11 '17 by Satō Katsura
1
vote
Because otherwise the owner of the root directory would be able to escalate privileges to root, f.i. by renaming /etc and creating a new one, and a new /etc/passwd.
answered Oct 9 '17 by Satō Katsura
1
vote
One way to do it, assuming GNU stat(1) and GNU truncate(1): #! /bin/sh lines=1000000 size=$( wc -l "$1" | awk '{print $1}' ) tail=$(( size % lines )) count=$(( size / lines )) if [ $tail -ne 0 ]; …
answered Nov 29 '16 by Satō Katsura
2
votes
Assuming your filenames don't have embedded newlines: find /some/dir -type f -name '*.jpg' | shuf | head -1 There are much better ways to do it from a web server though.
answered Sep 28 '16 by Satō Katsura
1
vote
might have ported a Linux distro to it. Some tablets even allow dual boot, others can't be modified at all (that is, there is no known way to root them). …
answered Jul 24 '15 by Satō Katsura
1
vote
sleep is designed to consume almost no resources. Beware however that sleep can be interrupted for various reasons. You probably want to make sure you don't run your commands (much) earlier than int …
answered Nov 1 '17 by Satō Katsura
3
votes
for setting preferred applications for opening files based on their MIME types. On Linux it's used by all major desktop environments. The latter is available only on certain Linux distributions, and …
answered Jun 9 '17 by Satō Katsura
7
votes
You need to quote del-non-*-locales.sh*. The first run works because you don't have any file in the current directory matching del-non-*-locales.sh*, so by default the pattern expands to itself (with …
answered Nov 9 '17 by Satō Katsura
2
votes
From man chage: -R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. So just chroot to the mount point o …
answered Sep 17 '17 by Satō Katsura
7
votes
It's possible if the target system uses shadow passwords, and /etc/shadow is not overridden by other mechanisms (via PAM, nss, etc.), and the target system doesn't hash /etc/shadow, and the target s …
answered Oct 30 '17 by Satō Katsura
5
votes
Since you tagged this linux I'll assume you have GNU find and GNU tar. If your filenames don't have embedded newlines and you don't want to archive empty directories: find "$3" -type f \! -empty …
answered May 31 '17 by Satō Katsura
3
votes
With bash: str1=$(echo -ne "\x01\x02" | base64) str2=$(echo -ne "\x03\x04" | base64) if [[ $str1 =~ =$ ]; then concat=$( { base64 -d <<<"$str1"; base64 -d <<<"$str2"; } | base64 ) else concat …
answered Jun 8 '17 by Satō Katsura
1
vote
With awk: awk -F ' *, *' -v OFS='\n' '{ NF=NF } 1' file.csv With GNU sed: sed 's/ *, */\n/g' file.csv
answered Mar 22 '17 by Satō Katsura
3
votes
With Perl rename: prename -n 's!t10n(\d+)/data/file.dat\K(\d+)!$1*5+$2!e' t10n*/data/file.dat* Remove -n when you're happy with the result.
answered Oct 5 '17 by Satō Katsura

15 30 50 per page