Tag Info

Hot answers tagged

25

You can use the echo or find commands instead of ls: echo * or: find -printf "%M\t%u\t%g\t%p\n"


23

You can also use the printf command, instead of echo: printf '%s\n' * printf is superior to echo in this situation in that echo does not respect the "double dash" (--) to signify the end of the argument list (on some systems, including Ubuntu 14.04 which is what I tested it on): llama@llama:~$ mkdir -p Misc/unix210948 llama@llama:~$ cd !$ cd ...


11

POSIX defines uname ("Unix name") to provide information about the operating system and hardware platform; running uname gives the name of the implementation of the operating system (or according to the coreutils documentation, the kernel). You can do this interactively in a terminal, or use the output in a script. On Linux systems, uname will print Linux. ...


9

In modern systems none of the memory is actually copied just because a fork system call is used. It is all marked read only in the page table such that on first attempt to write a trap into kernel code will happen. Only once the first process attempt to write will the copying happen. This is known as copy-on-write. However it may be necessary to keep track ...


8

Append shutdown -r 60 to /etc/rc.local.


8

Simply append the * character to the a variable, instead of the loop counter: for i in {1..5} do a+='*' echo "${a}" done Note that a="${a}*" instead of a+='*' works just as well, but I think the += version is neater/clearer. If you want to do this with a while loop instead, you could do something like this: while (( "${#a}" < 5 )); do a+='*' ...


7

Yes, all the scripts and programs are directly called by root. The /etc/rc.local file is called directly by the init process.


7

You should probably use the file and uname utilities to get a better idea of just what the hell is going on with your machine. Your error is indicative of a binary executable compiled for a system architecture incompatible with that on which it is invoked. On my machine: uname -m; file /bin/ls ...prints... x86_64 /bin/ls: ELF 64-bit LSB executable, ...


7

According to man bash: When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands ...


6

"Text file busy" means a process is trying to modify an executable while it's running ("text" is about a .text segment, not a text file). To trigger it: $ cp /usr/bin/yes . $ ./yes >/dev/null & [1] 27417 $ cat /dev/null >yes -bash: yes: Text file busy $ kill %1 [1]+ Terminated ./yes > /dev/null $ cat /dev/null >yes $ ls ...


6

That's the job for uniq: LC_ALL=C uniq file GNU uniq in some locales can report first of sequences of lines that sort the same. Using LC_ALL=C forced bytes comparison behavior, give you persistent result.


6

In general, libraries have three different types of memory that is loaded from the file. These are: code -- The actual executable code in the library rodata -- Read only data (constant values). data -- Writeable data. These are mapped with different permissions. If you look at the first line of each mapping: 7f1a09696000-7f1a0982f000 r-xp 00000000 fe:04 ...


5

Digital Trauma's answer is more efficient in this case, but just for completeness' sake you could use the traditional shell method of repeating characters using printf: for i in {1..5} do printf "%${i}s\n" done | sed 's/ /*/g' This uses printf to output as many spaces as required, then sed to replace the spaces with the character we really want. As ...


5

nproc gives the number of CPU cores/threads available, e.g. 8 on a quad-core CPU supporting two-way SMT. The number of jobs you can run in parallel with make using the -j option depends on a number of factors: the amount of available memory the amount of memory used by each make job the extent to which make jobs are I/O- or CPU-bound make -j$(nproc) is ...


5

Using bash (or many other shells), you can use tab completion to list files: $ thisisnotacommand ./public_html/<TAB> acc/ papers/ android/ l/ sdr/ blast formalcss.html switch/ busy/ formalcss.tar.gz others/ together.jpg


5

Another perl: perl -pe 'BEGIN { binmode \*STDOUT } chomp; tr/AB/\0\1/; $_ = pack "B*", $_' Proof: $ echo ABBBAAAABBBBBABBABBBABBB | \ perl -pe 'BEGIN { binmode \*STDOUT } chomp; tr/AB/\0\1/; $_ = pack "B*", $_' | \ od -tx1 0000000 70 fb 77 0000003 The above reads input one line at a time. It's up to you to make sure the lines are exactly what ...


5

You could do something like: netns=myns find -L /proc/[1-9]*/task/*/ns/net -samefile /run/netns/"$netns" | cut -d/ -f5 Or with zsh: print -l /proc/[1-9]*/task/*/ns/net(e:'[ $REPLY -ef /run/netns/$netns ]'::h:h:t) It checks the inode of the file which the /proc/*/task/*/ns/net symlink points to agains those of the files bind-mounted by ip netns add in ...


4

Linux has a feature called network namespaces which allow you to essentially have multiple network stacks on the same machine, and assign one to a program when running it. This is a feature typically used for containers, but you can also use it to accomplish what you want. The ip netns subcommands manage it. Creating a new network namespace with no access ...


4

Historical reasons. Originally, before devfs existed, these device files were created by hand or by a script called MAKEDEV. This is also why many drivers have a fixed device number assignment; because the device numbers had to be known so that the device files would work properly. There aren't really any common use cases for the mknod command on modern ...


4

There is kernel setting /proc/sys/vm/overcommit_memory Citation from excellent article: Since 2.5.30 the values are: 0 (default): as before: guess about how much overcommitment is reasonable, 1: never refuse any malloc(), 2: be precise about the overcommit - never commit a virtual address space larger than swap space plus a fraction overcommit_ratio ...


4

You can monitor the opening/closing of files using the inotify subsystem. pyinotify is one interface to this subsystem. Note that if you have a lot of events going to inotify, some can be dropped, but it works for most cases (especially your case in which user interaction will drive the opening/closing of files). pyinotify is available via easy_install/pip ...


4

POSIXly: $ n=5 awk 'BEGIN{OFS="*";for(i=2;i<=ENVIRON["n"]+1;i++){$i="";print}}'


4

You can try Ctrl+Alt+F2, or F3 or F4... Unless it was changed in Fedora 22, graphical server is started on first terminal of Fedora instead of 7th in Ubuntu. P.S. If that works, use Ctrl+Alt+F1 to go back to graphical server.


4

If you don't mind your file ending up sorted, sort it and filter it; either sort -u file if your sort supports it, or sort file | uniq if not, and you'll get on standard output the sorted list of unique email addresses. If you want to keep the addresses in the original order, use awk: awk '!(count[$0]++)' file


4

The command chroot allows you to create a restricted root for a user, this question explains the concept of chroot and how to use it. Update: Searching for chroot jail set up on digital ocean, brings up further documentation specific to their environment. Here's a couple which I think are related to what you might need. How To Configure Chroot Environments ...


4

Restrictions are a sensible issue, and it must be defined consistently. What you can do is to define a restricted shell for the user as his default shell. For example, setting /bin/rksh (a restricted kornshell) instead of the user's predefined shell as the default shell for that user in /etc/profile. - Note: if the executable with this name is not existing ...


4

Sessions contain process groups which contain processes. Those were created mostly for terminal job control. A session is typically associated to a login session in a terminal, or the whole shell session in a terminal emulator. When you login or start xterm, a new process is created that starts a new session (which automatically starts a new process group) ...


4

You have misunderstood. The LUKS data is stored on disc and encrypted/decrypted a block at a time as necessary (of course there is some caching going on). I don't know the minimum size, but I operated a 32Gb LUKS encrypted ReiserFS partition from a 1 GB memory PC. A whole disc shouldn't make any difference from using LUKS on a partition.


4

At least three different utilities imaginatively named rename(1) are floating around in the Linux waters: (1) the one that came with util-linux, (2) an older Perl script by Larry Wall further munged by Tom Christiansen, and (3) a newer Perl script evolved from the former and included with Unicode::Tussle. As far as I can tell, what you want can't be done ...


4

It depends. Typically big corporations, or big corp wannabes, with somewhat bureaucratic in-house processes may be stupid to ignore someone really good without a formal degree. My impression is that a lot of companies don't care about your degree, though. If you have the know-how, you can do the job and do it well, your resume demonstrates that you're de ...



Only top voted, non community-wiki answers of a minimum length are eligible