Hot answers tagged

35

The fastest way to create a file in a Linux system is fallocate: fallocate -l 50G file From man: fallocate is used to manipulate the allocated disk space for a file, either to deallocate or preallocate it. For filesystems which support the fallocate system call, preallocation is done quickly by allocating blocks ...


34

The POSIX standard says A pathname consisting of a single / shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. It makes a distinction between filenames and pathnames. / is a pathname for the path of the root directory. The name of the directory is "the root directory", but in the filesystem it is ...


22

slash is a separator; directory names do not include separators, but full pathnames include the separators. So the "root-level" "/" has no name. On most Unix-like systems, this is treated as a special case like "." and ".." (though of course there is no difference between the two at the root level). Nomenclature can differ. POSIX, for example lists some ...


12

-g sets the initial, or primary, group. This is what appears in the group field in /etc/passwd. On many distributions the primary group name is the same as the user name. -G sets the supplementary, or additional, groups. These are the groups in /etc/group that list your user account. This might include groups such as sudo, staff, etc.


12

Other alternatives include: to change the alarm thresholds to something near or below the current usage, or to create a very small test partition with limited inodes, size, or other attributes. Being able to test things such as running into the root reserved percentage, if any, may also be handy.


11

In Unix, files (and directories are just files) don't have "names". Links have names, links are entries in a directory that map names to files. You might say, that links give names to files, but note: this implies that a file can have more than one name, since it can have more than one link. Since the root directory is, well, the root directory, there is ...


7

They are not the same. The -g option specifies the "primary" group that a user should belong to, while the -G option specifies one or many supplementary ("secondary") groups. On a work machine I have access to I have $ id uid=1001(me) gid=1001(me) groups=1001(me),27(sudo),110(lxd),1005(theproject) This shows that my "primary" group is me (same as my ...


6

They're not completely identical. In cases where it matters, the redirection approach will generally give more annoying and obscure results (of course that might be what you want though). $ cat < /proc/self/maps $ cat /proc/self/maps 55c61257e000-55c61258a000 r-xp 00000000 fd:00 1180143 /usr/bin/cat ... Or try grep, the search ...


6

You can use udevadm to get this information. For example on my system lspci gives me: # lspci|grep VGA 01:00.0 VGA compatible controller: NVIDIA Corporation GK106 [GeForce GTX 650 Ti Boost] (rev a1) Querying udev instead I get: # udevadm info -q property -p /sys/bus/pci/devices/0000:01:00.0 DEVPATH=/devices/pci0000:00/0000:00:02.0/0000:01:00.0 DRIVER=...


6

This can be done using dmsetup deps, which lists the block device's dependencies. By default, it'll return the major:minor device numbers, but you can provide additional options to output a name: dmsetup deps -o devname /dev/mapper/decrypted


5

I'm not sure if you're trying to convert lower to upper or remove lower all together. Give this a shot for the lower to upper conversion. tr [:lower:] [:upper:] < ws2.txt To trim out lowercase chars you can use sed sed -e 's/[a-z]//g' ws2.txt Or you can use tr as suggested by @fd0 tr -d '[:lower:]' < ws2.txt To trim out numbers and capital ...


5

fallocate -l 50G big_file truncate -s 50G big_file dd of=bigfile bs=1 seek=50G count=0 As those three ways can all fill up a partition quickly. If you like use dd, usually you can try it with seek. Just set seek=file_size_what_you_need and set count=0. That will tell the system there is a file, and its size is what you set, but the system will not create ...


5

Background /proc and /sys filesystems are just a view of kernel structures, both filesystems reside in memory. Although both filesystems are writable (well, some of the files in there are writable) it is unwise to assume that they behave the same way as a real filesystems. Operations that allow you to write into a file inside /proc or /sys end as hooks ...


5

OpenVSwitch is a virtual switch. It works by attaching to several Ethernet devices in raw packet/Ethernet mode. It switches Ethernet frames between those Ethernet devices by reading/writing raw Ethernet frames to/from those network interfaces. This is nice if you want to switch between real Ethernet devices. If you want to connect a VM to your Open V Switch ...


5

You have only Link-Local, non routable ipv6 (fe80::/10). So You have no public routable IPv6. In this configuration You can make ipv6 connect only to Link-Local addresses in same L2 segment.


5

cat's job is it to concatenate everything it gets and then to print it out on stdout yet often is used to print out the contents of a single file (which of course is just concatenating the contents of all the one files given to it and then writing it to stdout). stdout (standard output) is just programs usually write output data. (There are programs (like dd)...


5

On Linux-based platforms there is a netlink socket that you can open from your Java program and determine whether or not to accept the packet. This socket can be included in the network stack with an iptables rule. Here of course you can also limit the types of packets to be passed to your usermode filter. Here's what the man page has to say on the matter: ...


5

As OEL 6 using iptables; Allow ICMP traffic to leave your server, ie so you can ping out $ iptables -A OUTPUT -p icmp -o eth0 -j ACCEPT Then block IMCP replies: $ iptables -A INPUT -p icmp --icmp-type echo-reply -j DROP $ iptables -A INPUT -p icmp --icmp-type echo-request -j DROP SSH would be the same, assuming SSH is on port 22. $ iptables -A ...


5

To understand what every file is responsible for you should understand how MPU starts up. As I understood from your qestion you use NXP (Freescale) i.MX microprocessor family. It includes small ROM loader, which will make basic system setup (interfaces to memory, clock tree etc.), search for media to boot from (based on burned OTP bits or GPIO), find ...


5

The awk solution: awk '{ getline a <"file2" split(a,A) for(i=1;i<=NF;i++) printf("%s_%s ", $i, A[i]) print "" }' file1 paste + sed: paste file1 file2 | sed ' :a s/\(\(^\|\s\)[^_[:blank:]]\+\b\)\s*\(.*\t\)\(\S\+\)\s*/\1_\4 \3/ ta s/\s*$// ' bash loop: exec 3<file1 4<file2 while read -u 3 a ; ...


5

Wow okay well have you considered just removing the user? userdel john As others have mentioned login as root over ssh is ill advised and so is having duplicate uid's of 0.


4

When you press Enter, the full command is already on the remote machine. There is no guarantee that this will not cause a disconnect but the reason it hasn't impacted your session so far is that the system didn't have time to notice the disconnection which actually happened. Processes which are receiving data while it gets disconnected will probably ...


4

Use the metric directive in the interfaces. The higher the value, the lower the priority. allow-hotplug eth0 iface eth0 inet static address 192.168.20.2 netmask 255.255.255.0 gateway 192.168.20.1 metric 30 allow-hotplug wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf metric 10 Then restart networking ...


4

The Arduinos can all be fine sendmail email to the outside without (direct) Internet access. For that you need to: setup a email relay in port 25, for instance postfix, in a box with Internet access, authorising your internal network, or the arduino network in case they are a separate lan/VLAN use APIs in your code for sendmail mail from the Arduinos that ...


4

This will go through your files and set the executable bit according to whether file believes that the file should be executable: find /var/www/html -type f -exec bash -c 'if file -b "$1" | grep -q executable; then chmod +x "$1"; else chmod -x "$1"; fi' None {} \; The find command is very similar to yours. The change is the addition of the bash commands. ...


4

The ... 1&2>> ... is viewed as ... 1& and then 2>> .... In other words, it starts the first part in the background, creates a log file, and try to start 2 which certainly does nothing. So no output is sent to that log file. I usually do something like 2>&1 to say to send stderr to stdout. You have to define stdout first if you ...


4

When a program has connections, and after you kill the process, a timeout can be defined for the port to linger. The involved kernel variables to change that timeouts are: From: Linux TCP Tuning /proc/sys/net/ipv4/tcp_tw_reuse - This allows reusing sockets in TIME_WAIT state for new connections when it is safe from protocol viewpoint. Default ...


4

On OpenBSD the divert(4) mechanism can be used to lob packets between the kernel and an arbitrary userland process written in an arbitrary language, assuming the language can be made to interface with the system call (either directly or possibly via the additional complication of a shim divert(4)-to-whatever-IPC-is-required proxy layer should the language ...


4

The only way is to have a directory that the user can't write to. Create a single file in that directory and give them permission to write that file. They won't be able to remove the file nor to create another file. They won't be able to rename the file either. But they can overwrite the file, and they can change the file's metadata (timestamps, permissions, ...


4

When you connect to a remote by ssh -X this automatically sets up a reverse channel, over the same connection, to your originating display. It uses the first free port starting from 6010 and initialises DISPLAY to this minus 6000. If you are getting localhost:11.0 then probably someone else has already connected and taken that port, so you get the next one. ...



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