Tag Info

Hot answers tagged

13

Yes, you can do this by accessing the master key while the volume is decrypted. The quick and dirty to add a new passphrase: device=/dev/sda5 volume_name=foo cryptsetup luksAddKey $device --master-key-file <(dmsetup table --showkeys $volume_name | awk '{ print $5 }' | xxd -r -p) device and volume_name should be set appropriately. volume_name is the ...


12

Simply add N to the end of the command for it to match the Nth match, like this: uname -r | sed 's/\./ /2' What do you need it for though? From the info page on sed: The `s' command can be followed by zero or more of the following FLAGS: g Apply the replacement to _all_ matches to the REGEXP, not just the first. NUMBER Only replace ...


10

There are various alternatives to udev out there. Seemingly Gentoo can use something called mdev. Another option would be to attempt to use udev's predecessor devfsd. Finally, you can always create all the device files you need with mknod. Note that with the latter there is no need to create everything at boot time since the nodes can be created on disk and ...


9

Potential Method #1 - F_DROP_CACHES I found a method from 2012 that discusses a proposed patch to the Linux kernel in this mail thread titled: Re: [RFC Patch] fs: implement per-file drop caches. excerpt Cong> This is a draft patch of implementing per-file drop caches. Interesting. So can I do this from outside a process? I'm a SysAdmin, so my ...


7

Check the kernel documentation for information about files in /proc. There is one such file per process because not all processes see the same mount points. Chroot is a traditional Unix feature that makes it possible to restrict processes to a subtree of the filesystem tree. A chrooted process would not see mount points outside its root. Linux takes this ...


7

Because those programs are build to use things defined in the kernel headers: busybox-1.22.1]$ egrep -RHn '^#include <linux' modutils/modutils-24.c:194:#include <linux/elf-em.h> include/fix_u32.h:17:#include <linux/types.h> libbb/loop.c:11:#include <linux/version.h> console-tools/openvt.c:23:#include <linux/vt.h> ...


7

Modern Linux kernels support the devtmpfs file system (do not confuse with ancient devfs), which creates all device nodes dynamically as soon as the kernel discovers them. (In fact, latest udev releases require this; you'll find that udev doesn't create any device nodes anymore, only symlinks.) Similarly, firmware loading has been moved into the kernel as ...


6

I don't think this is possible. Theoretically what you'll want to do is: Move the system to the "single" run level by using init 1, where theoretically you only have init and bash running. Unmount all the partitions except / . at this point your system may stop working, depending on whether /usr is on the root partition. Mount your other os's root ...


6

How about: while read code device state junk; do if [[ $code == $message ]]; then echo "Translated: $device-$state" fi done <CODE-LIST.txt Using extra processes (i.e. forking awk everytime) will slow it a lot. read will read multiple fields, separated by $IFS (default value is all white space). The last variable listed will receive the ...


6

It's considered unsafe to edit .config because there are CONFIG-options which have dependencies on other options (needing some to be set, requiring others to be turned off, etc.). Other options aren't meant to be set by the user at all, but are set automatically by make config (resp. Kconfig to be correct) depending on architecture details, e.g. ...


5

If you can rely on Bash builtin regular expressions (namely the =~ operator) and array variables, you can use something like this: #!/bin/bash W1=( $( echo "$1" | sed "s/./\n&/g" | sort -u ) ) W2="$2" set ${W1[*]} while [[ ! -z "$1" ]]; do if [[ "$W2" =~ "$1" ]]; then printf "$1 " fi shift done printf "\n" The first line creates ...


5

What you see is effect of a standard stdout buffer in grep provided by Glibc. The best solution is to disable it by using --line-buffered (GNU grep, I'm not sure what other implementations might support it or something similar). As for why this only happens in some cases: ssh server "tail -f /var/log/server.log | grep test" runs the whole command in the ...


5

You can change that with setterm -blank X (X is the number of minutes). From man setterm: -blank [0-60|force|poke] (virtual consoles only) Sets the interval of inactivity, in minutes, after which the screen will be automatically blanked (using APM if available). Without an argument, gets the blank status (returns which vt ...


5

Process substitution results in a special file (like /dev/fd/63 in your example) that behaves like the read end of a named pipe. This file can be opened and read, but not written, not seeked. Commands that treat their arguments as pure streams work while commands that expect to seek in files they are given (or write to them) won't work. The kind of command ...


4

I won't say exactly how to do it, because this is obviously homework and the point is that you should learn by yourself and not just copy off of answers here. But I will give you some hints on how to figure it out. First, you need to find out which directory ls lives in. If you don't know how to do that, search the web. A good search term might be "how do ...


4

following is a simple approach that iterates over the first string and checks if each character is present in the second string, if the character is present then it will print that on the console. str1=$1; i=0 while [ $i -ne ${#str1} ] do c=${str1:$i:1} if [[ $2 == *$c* ]] then echo $c fi ((i++)) done


4

There's one big issue here: under the linux console there's no way to distinguish Ctrl-Down from Down, they both send the same ^[[B sequence. To make it work we'd need to find a hack for the linux console to change that. Not pretty, but if you care enough about it it might be possible. Otherwise, how about using another key binding ? Say Alt-/, Just need ...


4

On debian, you will have sysv scripts, Upstart jobs, and systemd services all installed at once. With Upstart and systemd, the jobs/services will be used if available, and the sysv scripts will be run if no Upstart or systemd jobs/services are available. This command returning success means Upstart was booted: test -x /sbin/initctl && /sbin/initctl ...


4

You might be running into trouble because /dev/mem has holes in it: memory locations that don't exist can't be read. strings is designed to read a regular file (or pipe or other input stream) from beginning to end and assumes there can't be holes in its input. It probably aborts the first time it gets a read error, which would correspond to the first hole ...


4

The value can only be extended up to a theoretical maximum of 32768 for 32 bit systems or 4194304 for 64 bit.


4

Could use awk for the whole thing. Awk is also far quicker than while read loops. awk -vM="$Message" '$1==M{print "Translated:",$2"-"$3}' CODE-LIST.txt Explanation -vM="$Message" - Create a variable named M with the value from $Message $1==M - If the first field is equal to variable M($Message) {print "Translated:",$2"-"$3} - ...


4

The hostname command doesn't store the name anywhere but kernel memory. How the system decides what its name is at boot time depends on how the system is configured. Options range from reading a name from a file, to using DNS or /etc/hosts to set the name after a suitable network interface has been brought up.


4

hostname(1) is just a front-end to the sethostname(3) system call, which basically writes the hostname to where the kernel expects it to be stored. If you want the change to be permanent, as per general Unix philosophy you have to store it yourself. The precise location however depends heavily on your init system. For instance, OpenBSD’s init reads the ...


4

Take a look at this related U&L Q&A titled: Where does uname get its information from?. Information such as the hostname persists within a data structure within the Linux kernel, while the system is running. During a system's boot this information can be reattained through a variety of mechanisms that is typically distro specific. If you look at the ...


3

Why don't you directly give / as parameter to df -k? df -k / | tail -n +2 This will give the list without the header.


3

Add the FQDN hostname to /etc/sysconfig/network: HOSTNAME=host.example.bar After a system restart the hostname command (without any options) should display the FQDN. [user@host ~]# hostname host.example.bar This works on CentOS 5/6.


3

If you like snazzy little one-liners, and are OK with using common tools from GNU coreutils, then you can do something like this: comm -12 <( fold -w1 <<< "$1" | sort -u ) <( fold -w1 <<< "$2" | sort -u ) If you don't care about the case of the letters, you can switch $1 and $2 with ${1,,} and ${2,,} respectively. As well as the ...


3

I believe that on the Windows machine you can enter: arp -a at which point it will list all the MAC address and IP address the computer knows about. If it's not listed there, you could consider installing nmap on your Windows machine. Then, have nmap scan the whole subnet for devices: nmap -sP 192.168.1.0/24


3

quotes are all messed up. This should work echo -ne '\e[0;34m' Disk: '\e[m' "$(df -h)" "\n" Basically if you do managemac3$ df=`df -h` managemac3$ echo $df Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk0s2 233Gi 54Gi 179Gi 24% 14151768 46917672 23% / devfs 207Ki 207Ki 0Bi 100% 716 0 100% /dev map -hosts 0Bi 0Bi 0Bi 100% 0 0 ...


3

You can mount a windows network share via the mount command: mount -t cifs //server/share /mnt/ -o username=user server can be the ip or the hostname of the windows server. share is the name of the network share /mnt/ is the mountpoint in the local linux machine user is the username that has the needed privileges you will be prompted for the password ...



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