Questions tagged [linux]

NOTICE: All Linux questions must be related to programming; those that aren't will be closed. Use this tag only if your question relates to programming using Linux APIs or Linux-specific behavior, not just because you happen to run your code on Linux. If you need Linux support, you can try https://unix.stackexchange.com or the specific Linux distribution's Stack Exchange site like https://askubuntu.com or https://elementaryos.stackexchange.com/

GNU/Linux is a Unix-like computer operating system which consists of necessary user-space libraries and programs provided by GNU in Cambridge, Massachusetts and a kernel, developed by Linus Torvalds in Helsinki, Finland.

The GNU/Linux naming controversy is a dispute among members of the free and open-source software community over how to refer to the computer operating system commonly called .


Design

A GNU/Linux-based system is a modular Unix-like operating system. It derives much of its basic design from principles established in Unix during the 1970s and 1980s. Such a system uses a monolithic kernel that handles process control, networking, and peripheral and file system access. Device drivers are either integrated directly with the kernel or added as modules loaded while the system is running.

Separate projects that interface with the kernel provide much of the system's higher-level functionality. The GNU user land is an important part of most GNU/Linux-based systems, providing the most common implementation of the C library, a popular shell, and many of the common Unix tools which carry out many basic operating system tasks. The graphical user interface (or GUI) used by most GNU/Linux systems is built on top of an implementation of the X Window System.


Tag Usage

The tag on Stack Overflow is generally used for questions about:

  • programming against the APIs supplied by the operating system
  • the implementation of the kernel
  • programming tools and techniques for use on a Linux-based system.

Notable questions that probably don't belong are:

  • questions about using a desktop or laptop GNU/Linux system are better directed towards Super User, Unix & Linux, Ask Ubuntu, or Elementary OS if they're specifically about those distributions.
  • questions about administering GNU/Linux systems for other users and networking GNU/Linux systems in a context more complicated than a minimal home network are better directed towards Server Fault.

Many questions about GNU/Linux can also be properly tagged as , but some features are specific to GNU/Linux and are not found on other Unix™ and Unix-like operating systems. If you have questions about a specific distribution and version (e.g., , it may not be necessary to use this tag for that question.

A fair number of questions are questions about the command shell (bash by default on many systems), and are probably better tagged with and/or the particular shell you are interested in (, , , etc.).

Questions about the internals of the Linux kernel or regarding writing Linux kernel modules should be tagged .


Free Linux and GNU/Linux Books


Common GNU/Linux distributions

Distrowatch aggregates new release notices from these and hundreds of other GNU/Linux distributions, Phoronix keeps track of new GNU/Linux features and GNU/Linux Performance.


Other resources

Related tags

226061 questions
1071
votes
24 answers

How to permanently set $PATH on Linux/Unix

On Linux, how can I add a directory to the $PATH so it remains persistent across different sessions? Background I'm trying to add a directory to my path so it will always be in my Linux path. I've tried: export PATH=$PATH:/path/to/dir This works,…
Ali
  • 261,656
  • 265
  • 575
  • 769
1070
votes
14 answers

Where can I find php.ini?

A few years ago I installed Apache 2.2x and PHP 5.3.1 on a Linux server I maintain. I used .tar.gz's and built them as instructed (instead of rpms and what-have-you). And all was fine. Today I needed to install this which seems like a PHP library. …
necromancer
  • 23,916
  • 22
  • 68
  • 115
1057
votes
25 answers

Recursively counting files in a Linux directory

How can I recursively count files in a Linux directory? I found this: find DIR_NAME -type f ¦ wc -l But when I run this it returns the following error. find: paths must precede expression: ¦
Robert Buckley
  • 11,196
  • 6
  • 24
  • 25
1056
votes
32 answers

Exploring Docker container's file system

I've noticed with docker that I need to understand what's happening inside a container or what files exist in there. One example is downloading images from the docker index - you don't have a clue what the image contains so it's impossible to start…
user2668128
  • 39,482
  • 8
  • 27
  • 34
1019
votes
36 answers

How to get full path of a file?

Is there an easy way I can print the full path of file.txt ? file.txt = /nfs/an/disks/jj/home/dir/file.txt The dir> file.txt should print /nfs/an/disks/jj/home/dir/file.txt
Jean
  • 21,665
  • 24
  • 69
  • 119
989
votes
2 answers

How can I get the current date and time in the terminal and set a custom command in the terminal for it?

I have to check the time in a Linux terminal. What is the command for getting date and time in a Linux terminal? Is there a way in which we can set a custom function?
harshal
  • 10,252
  • 3
  • 18
  • 23
984
votes
12 answers

How does "cat << EOF" work in bash?

I needed to write a script to enter multi-line input to a program (psql). After a bit of googling, I found the following syntax works: cat << EOF | psql ---params BEGIN; `pg_dump ----something` update table .... statement ...; END; EOF This…
hasen
  • 161,647
  • 65
  • 194
  • 231
969
votes
10 answers

Given two directory trees, how can I find out which files differ by content?

If I want find the differences between two directory trees, I usually just execute: diff -r dir1/ dir2/ This outputs exactly what the differences are between corresponding files. I'm interested in just getting a list of corresponding files whose…
Mansoor Siddiqui
  • 20,853
  • 10
  • 48
  • 67
934
votes
17 answers

open() in Python does not create a file if it doesn't exist

What is the best way to open a file as read/write if it exists, or if it does not, then create it and open it as read/write? From what I read, file = open('myfile.dat', 'rw') should do this, right? It is not working for me (Python 2.6.2) and I'm…
trh178
  • 11,228
  • 5
  • 28
  • 37
903
votes
9 answers

Redirect all output to file in Bash

I know that in Linux, to redirect output from the screen to a file, I can either use the > or tee. However, I'm not sure why part of the output is still output to the screen and not written to the file. Is there a way to redirect all output to…
Rayne
  • 14,247
  • 16
  • 42
  • 59
883
votes
31 answers

How can I measure the actual memory usage of an application or process?

How do you measure the memory usage of an application or process in Linux? From the blog article of Understanding memory usage on Linux, ps is not an accurate tool to use for this intent. Why ps is "wrong" Depending on how you look at it, ps is not…
ksuralta
  • 16,276
  • 16
  • 38
  • 36
866
votes
7 answers

Get current time in seconds since the Epoch on Linux, Bash

I need something simple like date, but in seconds since 1970 instead of the current date, hours, minutes, and seconds. date doesn't seem to offer that option. Is there an easy way?
n-alexander
  • 14,663
  • 12
  • 42
  • 43
864
votes
13 answers

How to 'grep' a continuous stream?

Is that possible to use grep on a continuous stream? What I mean is sort of a tail -f command, but with grep on the output in order to keep only the lines that interest me. I've tried tail -f | grep pattern but it seems that grep can…
Matthieu Napoli
  • 48,448
  • 45
  • 173
  • 261
864
votes
11 answers

Kill detached screen session

I learned from somewhere a detached screen can be killed by screen -X -S [session # you want to kill] kill where [session # you want to kill] can be gotten from screen -ls But this doesn't work. Anything wrong? What's the correct way?
Tim
  • 1
  • 141
  • 372
  • 590
856
votes
19 answers

How to force cp to overwrite without confirmation

I'm trying to use the cp command and force an overwrite. I have tried cp -rf /foo/* /bar, but I am still prompted to confirm each overwrite.
Thiyagarajan Varadharaj
  • 10,154
  • 5
  • 21
  • 18