Tag Info

Hot answers tagged

16

The "Everything is a file" phrase defines the architecture of the operating system. It means that everything in the system from processes, files, directories, sockets, pipes, ... is represented by a file descriptor abstracted over the virtual filesystem layer in the kernel. The virtual filesytem is an interface provided by the kernel. Hence the phrase was ...


15

dlopen isn't a system call, it's a library function in the libdl library. Only system calls show up in strace. On Linux and on many other platforms (especially those that use the ELF format for executables), dlopen is implemented by opening the target library with open() and mapping it into memory with mmap(). mmap() is really the critical part here, it's ...


6

The /sys directory is generally where the sysfs filestystem is mounted, which contains information about devices and other kernel information. The files in /sys/block contain information about block devices on your system. Your local system has a block device named sda, so /sys/block/sda exists. Your Amazon instance has a device named xvda, so ...


6

To logout from UNIX or Linux you can either: type exit and press [ENTER] on a command line where you haven't typed anything press [CTRL]-D to log out.


6

if a program supports streaming I/O it can work with files more than the size of the memory, is this correct Usually yes, but not necessarily. Imagine a program, like uniq but more sophisticated, that counts up the number of occurrences of each unique line it gets on its input. Unlike uniq it outputs a running total of the number of occurrences seen so ...


5

I don't think that there is a concept of "directory created by system". When you're installing your system, installation media often gets job done for you - you see the result(e.g. /etc directory created), but that really is done by user who happened to run script. Anything created by "system" could be treated as created by root, but there's no way of ...


5

POSIXly: find /test/. ! -name . -type d -mtime +0 -exec rm -rf {} \; -prune (we use -prune for the directories that we successfully remove so that find doesn't complain that they're suddenly gone). In any case, note that the modification time (as checked by -mtime above) of a directory file only reflects the last time an entry was added, removed or ...


4

Linux, like most Unix-like systems (Apple OS/X being one of the rare exceptions), ignores permissions on symlinks when it comes to resolving their targets for instance. However ownership of symlinks, like other files, is relevant when it comes to the permission to rename or unlink their entries in directories that have the t bit set, such as /tmp. To be ...


4

Turns out there was a LVM snapshot of the root filesystem's LV, but not the other. Appears snapshots block TRIM, because the device-mapper snapshot target doesn't support it.


3

Remember how I said: The system uses lxc containers for compartmentalisation, but that shouldn't matter here. Well, turns out it did matter. Or rather, the cgroups at the heart of lxc matter. The host machine only sees reboots for kernel upgrades. So, what were the last kernels used? 3.19, replaced by 4.0.5 2 months ago and yesterday with 4.1.3. And ...


3

I could reproduce the phenomenon on Ubuntu 15.04 with the following crontab: * * * * * { echo job 0; } & sleep 5 * * * * * { echo job 1; } & * * * * * { sleep 5; echo job 2; } & I got mails from cron with job 0 every minute, mails with job 1 occasionally (5-6 times in last 10 minutes), no mails with job 2. So it seems cron waits for the child ...


3

Upon further testing, I suspect the & is messing with your results. As you point out, &>/dev/null is bash syntax, not sh syntax. As a result, sh is creating a subshell and backgrounding it. Sure, the subshell's echo creates stderr, but my theory is that: cron is not catching the subshell's stderr, and the backgrounding of the subshell always ...


3

Your shell is smart enough to know that cd will not work with file parameters. So when you hit tab it only shows things in that directory that will work with cd.


3

You can use lightweight distributions that require less ram. Linux doesn't need 512MB. SWAP is kind of temporary substitution for RAM. You could use it, but it's much slower than RAM, and could make your experience unpleasant. Still, you can check out Puppy Linux requirements. It's known for being lightweight. Also, here you can see list of distributions ...


3

For the third version, you want "$*" not "$@". Explanation To illustrate, let's set some positional arguments: $ set -- arg1 arg2 arg3 Now, let's read them out with your echo formulation: $ printf "%s\n" "$(echo $@)" arg1 arg2 arg3 Let's see what "$@" does with them: $ printf "%s\n" "$@" arg1 arg2 arg3 The difference is that "$@" expands to three ...


3

I would keep it simple and clone it. Boot a live system from USB (easiest is Ubuntu from a USB thumb drive, I find), then dump your hard disk to a different partition (or external hard drive etc.), e.g. dd if=/dev/sda1 bs=64M of=/mnt/my_mounted_backup_drive/backup-sda1 where you need to replace /dev/sda1 with your root (/) partition. Do the same with ...


3

Yes. Recoll can regularly index your files and provide a search via your browser. It can search within files too. Recoll is a full-text search tool for Unix and Linux desktops. Recoll finds keywords inside documents as well as file names. It can search most document formats. You may need external applications for text extraction. It can ...


3

I can see that O'Reilly's "Understanding the Linux Kernel" by Mssrs Bovet and Cesati, page 714 (Swap Area), provides an answer to this question. To paraphrase, the swap_header is composed of two structures, "info" and "magic". The code I pasted above relates to the magic part - it literally writes out "SWAP-SPACE" as the final 10 characters of the first page ...


3

Don't use which (unless you're in csh or tcsh variants), it's broken. Using command -v node instead. POSIX offer dirname command to get the directory portion of pathname: cd "$(dirname -- "$(command -v node)")" or using a variable to store the pathname, prevent you from calling dirname: nodepath=$(command -v node) cd "${nodepath%/*}"


3

I can read the /proc/$PID/net/tcp file for example and get information about TCP ports opened by the process. That file is not a list of tcp ports opened by the process. It is a list of all open tcp ports in the current network namespace, and for processes running in the same network namespace is identical to the contents of /proc/net/tcp. To find ...


3

Using last you can find this information. The following may be useful: last <username> | less It will return something like this: benlavery@Talantinc:bin $>last benlavery | less benlavery ttys005 Mon Aug 31 09:58 still logged in benlavery ttys005 fe80::105e:6b27:29ff:d967%en0 Mon Aug 31 09:14 - 09:36 (00:22) benlavery ...


2

There is no difference between files (including directories) created by the system or by a user because in the end it is the same system call. Later on it is impossible to tell who was the owner of the process which created the file or directory. By the way, "the Linux system" is mostly the user root: there is no special user. Furthermore, installing always ...


2

Depending on what you mean by "created by system", you may be able to use the packaging system to determine how a particular directory was created. For example, on an RPM-based system (e.g. RedHat, Fedora, CentOS etc): rpm -qf /var will give something like filesystem-2.4.100.x86_64 indicating it was installed as part of the filesystem package, whereas ...


2

To start your service at the end, run this command update-rc.d homemadeserviceName defaults 99 This will add a link inside /etc/rc.d as, S99homemadeserviceName Upstart will start services in the order of their numeric suffix... S0, S1, S2... and finally S99 services.


2

You must also use the update-rc.d command. There is the remove option to remove it from the boot sequence. The script will remain in the init.d directory and you are still able to start and stop them with the service command.


2

Each loaded module has an entry in /sys/module. But there are also kernel components with an entry in /sys/module that are not loaded as modules. Each kernel component that can be built as a module has an entry in /sys/module, whether it is compiled and loaded as a module or compiled as part of the main kernel image. lsmod gets the list of loaded modules ...


2

You're probably using something which uses the framebuffer directly, without using X. It is not possible to display such things remotely. I don't know this emulationstation thing, but I can say that kodi works just fine with an X server. Also, it has its own android remote app which is a more useful way of controlling it from android; you might want to look ...


2

Both files contain the statistics of the first partition (/sys/block/sda1/stat) of the first device (/sys/block/sda1/stat) found by a particular driver or subsystem. The difference is the driver. Your amazon VM is using the Xen driver (/sys/block/xvda1/stat). Your local machine is using the SCSI driver (/sys/block/sda1/stat). xvd = Xen Virtual Disk sd ...


2

As @meuh said in his comment, you could use /test/* instead of /test. Your command could then look similar to this: find /test/* -type d -mmin +1440 | xargs rm -rf In this case only the subfolders of /test would be removed.


2

The simplest way is to run: getconf LONG_BIT which will return 64 or 32 depending on whether it is 32 or 64 bits. eg: dannyw@dannyw-redhat:~$ getconf LONG_BIT 64



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