Tag Info

Hot answers tagged

53

I ran this: strace -o spork.out bash -c "echo 1234 >> some-file" to figure out your question. This is what I found: open("some-file", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3 No file named "some-file" existed in the directory in which I ran the echo command.


50

I'll answer your questions in three parts: file types, permissions, and use cases for the various forms of chmod. File types The first character in ls -l output represents the file type; d means it's a directory. It can't be set or unset, it depends on how the file was created. You can find the complete list of file types in the ls documentation; those ...


43

This is all due to the fact that the X server is out-dated, ill-suitable for today's graphics hardware and basically all the direct video card communication is done as an extension ("patch") over the ancient bloated core. The X server provides no builtin means of synchronization between user rendering the window and the screen displaying a window, so the ...


42

This is not only done in Bash, it's required by the standard. From the Single Unix Specification: Appended output redirection shall cause the file whose name results from the expansion of word to be opened for output on the designated file descriptor. The file is opened as if the open() function as defined in the System Interfaces volume of POSIX.1-2008 ...


37

It can. There are 2 different out of memory conditions you can encounter in linux. Which you encounter depends on the value of sysctl vm.overcommit_memory (/proc/sys/vm/overcommit_memory) Introduction: The kernel can perform what is called 'memory overcommit'. This is when the kernel allocates programs more memory than is really present in the system. This ...


35

And now, the systemd answer. You're using, per the tag on your question, Red Hat Enterprise Linux. Since version 7, that has used systemd. None of the other answers are correct for the world of systemd; nor even are some of the assumptions in your question. Forget about runlevels; they exist, but only as compatibility shims. The systemd documentation ...


33

You should use the at command: $ sudo at 6:45 [sudo] password for root: warning: commands will be executed using /bin/sh at> poweroff at> <EOT> Don't type the <EOT>, but press Ctrl+D at the second at> prompt. The significant advantage of using at over using shutdown with a TIME argument, is that it involves real, persistent, ...


32

System 5 init will tell you only a small part of the story. There's a sort of myopia that affects the Linux world. People think that they use a thing called "System 5 init", and that is both what is traditional and the best place to start. Neither is in fact the case. Tradition isn't in fact what such people say it to be, for starters. System 5 init and ...


29

Yes! This is a big deal, and incredibly common. And there are two basic approaches. One way is simply with scripted installs, as for example used in Fedora, RHEL, or CentOS's kickstart. Check this out in the Fedora install guide: Kickstart Installations. For your simple case, this may be sufficient. (Take this as an example; there are similar systems for ...


25

No matter the fancy name used here, both are solutions to a specific problem: A better segregation solution than classic Unix chroot. Operating system-level virtualization, containers, zones, or even "chroot with steroids" are names or commercial titles that define the same concept of userspace separation, but with different features. Chroot was introduced ...


25

Looking in the source, it does use O_APPEND. For bash 4.3.30 in make_cmd.c line 710-713 read: case r_appending_to: /* >>foo */ case r_append_err_and_out: /* &>> filename */ temp->flags = O_APPEND | O_WRONLY | O_CREAT; break;


24

A new install will seldom break your system (unless you do weird stuff like mixing source and binary). If you use precompiled binaries in Ubuntu then you can remove them and not have to worry about breaking your system, because a binary should list what it requires to run and your package manager will list what programs rely on that program for you to ...


22

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 ...


22

SCSI is not only a type of hardware interface, but also a command protocol, which is used for abstraction of most of the modern storage devices. Linux scsi driver is a high level driver that handles a variety of storage hardware. Protocol: http://en.wikipedia.org/wiki/SCSI_command Extract from SCSI on wikipedia: Other technologies which use the SCSI ...


21

Here are the commands you need to run, if you just want to get it done: sudo add-apt-repository ppa:git-core/ppa -y sudo apt-get update sudo apt-get install git git --version As of Dec 2014, I get git 2.2.0 that way, while the version in the Ubuntu Trusty repositories is 1.9.1. Note that add-apt-repository is installed via: sudo apt-get install ...


21

This is very easy to accomplish: #!/bin/sh [ "$(whoami)" != "root" ] && exec sudo -- "$0" "$@" When the current user isn't root, re-exec the script through sudo. Note that I am using sudo here instead of su. This is because it allows you to preserve arguments. If you use su, your command would have to be su -c "$0 $@" which would mangle your ...


20

The 1 GiB limit for Linux kernel memory in a 32-bit system is a consequence of 32-bit addressing, and it's a pretty stiff limit. It's not impossible to change, but it's there for a very good reason; changing it has consequences. Let's take the wayback machine to the early 1990s, when Linux was being created. Back in those days, we'd have arguments about ...


20

I checked uname manual (man uname) and it says the following for the "-a" option: print all information, in the following order, except omit -p and -i if unknown In Ubuntu, I guess, options "-m", "-p" and "-i" (machine, processor and hardware-platform) are returning the machine architecture. For example, if you use the command uname -mpi You will ...


19

Consider this scenario: You have 4GB of memory free. A faulty process allocates 3.999GB. You open a task manager to kill the runaway process. The task manager allocates 0.002GB. If the process that got killed was the last process to request memory, your task manager would get killed. Or: You have 4GB of memory free. A faulty process allocates 3.999GB. ...


19

Yes and no. *nix has a huge advantage over Windows in package management. Unlike in Windows where you must rely on third-party packages to have sane (un)installers, *nix distributions offer package managers that take care of installation and uninstallation in a unified manner. As a result, when you remove a package, all the system-level files for that ...


19

You can use shutdown: sudo shutdown -h 06:45 & And to check it: ps -aux | grep shutdown If you want to cancel it: sudo shutdown -c This assumes of course that the shutdown time has already passed.


18

Answer to my question, from Qualys: During our testing, we developed a proof-of-concept in which we send a specially created e-mail to a mail server and can get a remote shell to the Linux machine. This bypasses all existing protections (like ASLR, PIE and NX) on both 32-bit and 64-bit systems. My compiled research below for anyone else ...


18

You can do it with single command with sed 's/\(.*\)-/\1 /' The point is that sed is very greedy, so matches as many characters before - as possible, including other -. $ echo 'swp-RedHat-Linux-OS-5.5.0.0-03' | sed 's/\(.*\)-/\1 /' swp-RedHat-Linux-OS-5.5.0.0 03


17

The uname utility gets its information from the uname() system call. It populates a struct like this (see man 2 uname): struct utsname { char sysname[]; /* Operating system name (e.g., "Linux") */ char nodename[]; /* Name within "some implementation-defined network" */ char ...


17

You can write to /dev/random because it is part of the way to provide extra random bytes to /dev/random, but it is not sufficient, you also have to notify the system that there is additional entropy via an ioctl() call. I needed the same functionality for testing my smartcard setup program, as I did not want to wait for my mouse/keyboard to generate enough ...


17

It is because of NPTL. Since it is part of the GNU C library nearly every modern linux distribution don't uses the first two real time signals anymore. NPTL is an implementation of the POSIX Threads. NPTL makes internal use of the first two real-time signals. This part of the signal manpage is very interesting: The Linux kernel supports a range of 32 ...


17

halt instructs the hardware to stop all CPU functions, but leaves it in a powered-on state. This usually means someone has to reboot or shut the machine down manually by pressing the power button afterwards. The specific way to achieve this is architecture specific, but for instance the x86 instruction set provides the HLT instructions which halts the ...


17

fork() was the original UNIX system call. It can only be used to create new processes, not threads. Also, it is portable. In Linux, clone() is a new, versatile system call which can be used to create a new thread of execution. Depending on the options passed, the new thread of execution can adhere to the semantics of a UNIX process, a POSIX thread, ...


16

The short answer is no. The driver support for the same kernel version is configurable at compile time and also allows for module loading. The actual devices supported in a distro therefore depend on the included compiled in device drivers, compiled loadable modules for devices and actual installed modules. There are also devices not included in the ...


16

change the age of password to 0 day syntax chage -d 0 {user-name} In this case chage -d0 foo This works for me over ssh also



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