Tag Info

Hot answers tagged

287

System calls aren't handled like regular function calls. It takes special code to make the transition from user space to kernel space, basically a bit of inline assembly code injected into your program at the call site. The kernel side code that "catches" the system call is also low-level stuff you probably don't need to understand deeply, at least at ...


147

Generally, you should use kill -15 before kill -9 to give the target process a chance to clean up after itself. (Processes can't catch or ignore SIGKILL, but they can and often do catch SIGTERM.) If you don't give the process a chance to finish what it's doing and clean up, it may leave corrupted files (or other state) around that it won't be able to ...


116

Randal Schwartz used to frequently post "Useless use of (x)" on lists. One such post was about kill -9. It includes reasons and a recipe to follow. Here is a reconstructed version (quoted below). (Quote abomination) No no no. Don't use kill -9. It doesn't give the process a chance to cleanly: 1) shut down socket connections 2) clean up temp files ...


106

su - invokes a login shell after switching the user. A login shell resets most environment variables, providing a clean base. su just switches the user, providing a normal shell with an environment nearly the same as with the old user. Imagine, you're a software developer with normal user access to a machine and your ignorant admin just won't give you root ...


102

That depends on what you mean by “Unix”, and by “Linux”. UNIX is a registered trade mark of The Open Group. The trade mark has had an eventful history, and it's not completely clear that it's not genericized due to the widespread usage of “Unix” refering to Unix-like systems (see below). Currently the Open Group grants use of the trade mark to any system ...


94

The forward slash / is the delimiting character which separates directories in paths in Unix-like operating systems. This character seems to have been chosen sometime in the 1970's, and according to anecdotal sources, the reasons might be related to that the predecessor to Unix, the Multics operating system, used the > character as path separator, but the ...


68

Don't go straight to du /. Use df to find the partition that's hurting you, and then try du commands. One I like to try is du -h <dir> | grep '[0-9]G' because it prints sizes in "human readable form". Unless you've got really small partitions, grepping for directories in the gigabytes is a pretty good filter for what you want. This will take ...


66

When applying permissions to directories on Linux, the permission bits have different meanings than on regular files. The write bit allows the affected user to create, rename, or delete files within the directory, and modify the directory's attributes The read bit allows the affected user to list the files within the directory The execute bit allows the ...


58

It appears that you are confusing two very different parts of the OS. It's understandable, because they are often referred to interchangably, but it's technically incorrect, so your question is based on a faulty premise. In order to fully explore and hopefully answer the question that you likely want to ask, a short history lesson is needed. First, there ...


51

This probably doesn't answer your question directly, but I've found strace to be really cool when trying to understand the underlying system calls, in action, that are made for even the simplest shell commands. e.g. strace -o trace.txt mkdir mynewdir The system calls for the command mkdir mynewdir will be dumped to trace.txt for your viewing pleasure.


51

/proc/$pid/maps /proc/$pid/mem shows the contents of $pid's memory mapped the same way as in the process, i.e., the byte at offset x in the pseudo-file is the same as the byte at address x in the process. If an address is unmapped in the process, reading from the corresponding offset in the file returns EIO (Input/output error). For example, since the first ...


51

With host from the dnsutils package: $ host unix.stackexchange.com unix.stackexchange.com has address 64.34.119.12 (Corrected package name according to the comments. As a note other distributions have host is different packages: Ubuntu bind9-host, openSUSE bind-utils, Frugalware bind.)


50

If you want to know what's different so you can use the system more efficiently, here is a commonly referenced introduction to BSD to people coming from a Linux background. If you want more of the historical context for this decision, I'll just take a guess as to why they chose FreeBSD. Around the time of the first dot-com bubble, FreeBSD 4 was extremely ...


50

I came across this diagram which shows exactly this.     In the above you can see where tools such as strace, netstat, etc. interact with the Linux kernel's subsystems. I like this diagram because it succinctly shows where each tool latches on to the Linux kernel, which can be extremely helpful when you're first learning about all the tools ...


49

This is highly platform-dependent. Also different methods may treat edge cases differently (“fake” disks of various kinds, RAID volumes, …). On modern udev installations, there are symbolic links to storage media in subdirectories of /dev/disk, that let you look up a disk or a partition by serial number (/dev/disk/by-id/), by UUID (/dev/disk/by-uuid), by ...


49

As Heinzi said below, the best way is to use dig with the +short argument. dig +short unix.stackexchange.com If +short is unavailable for some reason, any one of the following should work: host unix.stackexchange.com | awk '/^[[:alnum:].-]+ has address/ { print $4 }' nslookup unix.stackexchange.com | awk '/^Address: / { print $2 }' dig ...


46

The {} syntax is Bash syntax not tied to the for construct. mkdir {A..Z} is sufficient all by itself. http://www.gnu.org/software/bash/manual/bashref.html#Brace-Expansion


44

There is a manual, you just have to know where it is. It can be accessed with the man command. If you are unsure how to use it, type man man. The man command is very important; remember it even if you forget everything else. The manual contains detailed information about a variety of topics, which are separated into several sections: General commands ...


44

The first hierarchical file system as we know it today was designed for Multics. The design is described in “A General-Purpose File System For Secondary Storage” by R.C. Daley and P.G. Neumann. A salient characteristic of this filesystem is that a directory is a file which can be contained in a directory like any other file. The file structure forms a tree, ...


42

In my mind, the only benefit you really get from compiling your own linux kernel is: You learn how to compile your own linux kernel. It's not something you need to do for more speed / memory / xxx whatever. It is a valuable thing to do if that's the stage you feel you are at in your development. If you want to have a deeper understanding of what this ...


40

As Gilles says, use gai.conf Say we have two hosts www.he.net and www.ripe.net $ host www.he.net www.he.net is an alias for he.net. he.net has address 216.218.186.2 he.net has IPv6 address 2001:470:0:76::2 $ host www.ripe.net www.ripe.net has address 193.0.6.139 www.ripe.net has IPv6 address 2001:67c:2e8:22::c100:68b Case 1: Prefer IPV4 Append the ...


39

While -R is posix well-defined, -r is not portable! On Linux, in the GNU and BusyBox implementations of cp, -r and -R are equivalent. On the other side, as you can read in the POSIX manual page of cp, -r behavior is implementation-defined. * If neither the -R nor -r options were specified, cp shall take actions based on the type and ...


39

You can try Ctrl+Alt+* to kill the front process (Screen locking programs on Xorg 1.11) or Ctrl+Alt+F1 to open a terminal, launch a command like ps or top to see running processes and launch kill on not responding process.


37

The whole ABI is different, not just the binary format (Mach-O versus ELF) as sepp2k mentioned. For example, while both Linux and Darwin/XNU (the kernel of OS X) use sc on PowerPC and int 0x80/sysenter/syscall on x86 for syscall entry, there's not much more in common from there on. Darwin directs negative syscall numbers at the Mach microkernel and ...


36

On a 32-bit architecture, the address space range for addressing RAM is: 0x00000000 - 0xffffffff or 4'294'967'295 (4 GB). The linux kernel splits that up 3/1 (could also be 2/2, or 1/3) into user space (high memory) and kernel space (low memory) respectively. The user space range: 0x00000000 - 0xbfffffff Every newly spawned user process gets an ...


36

Linux has wide support for lots of different hardware architectures and platforms from tiny embedded boards to massive computing arrays. While other good kernels are available, the coverage and quality of hardware drivers available for Linux far surpass any other platform. The Linux kernel source is open and can easily be modified to run on various custom ...


36

A couple of things come to mind: Recover from a kernel panic A kernel panic, by definition, cannot be recovered from without restarting the kernel. Recover from hangs which leave you without terminal access If the system is unresponsive and you're stranded without a way to issue commands to recover, the only thing you might be able to do is to reboot. ...


36

du can be depth-restricted: du -d 5 Will only recurse to depth 5. /EDIT: This counts only for the display; the tool will still determine the total size of the whole directory tree but this is still much faster than running a full du.


35

A good way to inspect what a command is: type l If it's a program or a script, it will give you its location, if it is an alias, it will tell you what it's aliased to, if it's a function, it will print the funciton; otherwise, it will tell you if it is a built-in or a keyword. Examples: $ type find find is /usr/bin/find $ type connecthome connecthome is ...


35

First, think: What is a directory? It's just a list of items (files and other directories) that live within. So: directory = list of names. Read bit = If set, you can read this list. So, for example, if you have a directory named poems: You can ls poems and you'll get a list of items living within (-l won't reveal any details!). You can use command-line ...



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