Questions tagged [linux]

These questions are about Linux in general – NOT specific to a particular distribution.  If the question just happens to be in a Linux environment, please specify your Linux distribution in the body of your question, but do NOT use the “linux” tag.

Filter by
Sorted by
Tagged with
525 votes
9 answers

Execute vs Read bit. How do directory permissions in Linux work?

In my CMS, I noticed that directories need the executable bit (+x) set for the user to open them. Why is the execute permission required to read a directory, and how do directory permissions in Linux ...
Nick.h's user avatar
  • 6,333
96 votes
6 answers

Understanding UNIX permissions and file types

I've never really got how chmod worked up until today. I followed a tutorial that explained a big deal to me. For example, I've read that you've got three different permission groups: owner (u) ...
Peter's user avatar
  • 1,031
21 votes
3 answers

What are the different ways to set file permissions, etc., on GNU/Linux?

On Unix, a long time back, I learned about chmod: the traditional way to set permissions on Unix (and to allow programs to gain privileges, using setuid and setgid). I have recently discovered some ...
ctrl-alt-delor's user avatar
252 votes
20 answers

How can I get distribution name and version number in a simple shell script?

I'm working on a simple bash script that should be able to run on Ubuntu and CentOS distributions (support for Debian and Fedora/RHEL would be a plus) and I need to know the name and version of the ...
Alix Axel's user avatar
  • 2,929
193 votes
14 answers

Recover deleted files on Linux

Is there a command to recover/undelete deleted files by rm? rm -rf /path/to/myfile How can I recover myfile? If there is a tool to do this, how can I use it?
pylover's user avatar
  • 3,428
398 votes
1 answer

How do you empty the buffers and cache on a Linux system?

Prior to doing some benchmarking work how would one free up the memory (RAM) that the Linux Kernel is consuming for its buffers and cache? Note that this is mostly useful for benchmarking. Emptying ...
slm's user avatar
  • 370k
75 votes
5 answers

Moving Linux install to a new computer

I know that it can, in some circumstances, be difficult to move a Windows installation from one computer to another (physically move the hard drive), but how does that work on Linux? Aren't most of ...
Falmarri's user avatar
  • 13.1k
56 votes
6 answers

How do I use swap space for emergencies only?

I have a Debian (Buster) laptop with 8 GB RAM and 16GB swap. I'm running a very long running task. This means my laptop has been left on for the past six days while it churns through. While doing ...
Philip Couling's user avatar
250 votes
12 answers

Limit memory usage for a single Linux process

I'm running pdftoppm to convert a user-provided PDF into a 300DPI image. This works great, except if the user provides an PDF with a very large page size. pdftoppm will allocate enough memory to ...
Ben Dilts's user avatar
  • 2,603
210 votes
9 answers

Is Linux a Unix?

So, there are lots of different versions of Unix out there: HP-UX, AIX, BSD, etc. Linux is considered a Unix clone rather than an implementation of Unix. Are all the "real" Unices actual descendants ...
Shawn J. Goff's user avatar
20 votes
2 answers

Why is there a discrepancy in disk usage reported by df and du? [duplicate]

I have a Linux CentOS server, the OS+packages used around 5GB. Then, I transferred 97GB data from a Windows server to two folders on this Linux server, after calculated the disk usage, I see the total ...
garconcn's user avatar
  • 315
369 votes
5 answers

How to set default file permissions for all folders/files in a directory?

I want to set a folder such that anything created within it (directories, files) inherit default permissions and group. Lets call the group "media". And also, the folders/files created within the ...
Chris's user avatar
  • 8,540
171 votes
6 answers

How do I read from /proc/$pid/mem under Linux?

The Linux proc(5) man page tells me that /proc/$pid/mem “can be used to access the pages of a process's memory”. But a straightforward attempt to use it only gives me $ cat /proc/$$/mem /proc/self/...
Gilles 'SO- stop being evil''s user avatar
436 votes
9 answers

When should I not kill -9 a process?

I am always very hesitant to run kill -9, but I see other admins do it almost routinely. I figure there is probably a sensible middle ground, so: When and why should kill -9 be used? When and why ...
Mikel's user avatar
  • 57.4k
283 votes
24 answers

Efficiently delete large directory containing thousands of files

We have an issue with a folder becoming unwieldy with hundreds of thousands of tiny files. There are so many files that performing rm -rf returns an error and instead what we need to do is something ...
Toby's user avatar
  • 3,993
89 votes
4 answers

How to run a script with systemd right before shutdown?

What do I need to put in the [install] section, so that systemd runs /home/me/ right before shutdown and also before /proc/self/net/dev gets destroyed? [Unit] Description=Log Traffic [Service] ...
sid_com's user avatar
  • 1,571
114 votes
11 answers

Block network access of a process?

Is it possible to block the (outgoing) network access of a single process?
larkee's user avatar
  • 1,243
39 votes
5 answers

Linux file access monitoring

Is there any way in unix to find out who accessed certain file in last 1 week? It may be user or some script ftp it to some other place. Can I get a list of user name who accessed certain file? How ...
Jack's user avatar
  • 391
29 votes
2 answers

How to change a file in-place using awk? (as with "sed -i")

I have an awk script, new.awk: BEGIN { FS = OFS = "," } NR == 1 { for (i = 1; i <= NF; i++) f[$i] = i } NR > 1 { begSecs = mktime(gensub(/[":-]/, " ", &...
mittu's user avatar
  • 407
39 votes
7 answers

Linux equivalent to PowerShell's "one-to-many" remoting

Coming from Windows administration, I want to dig deeper in Linux (Debian). One of my burning questions I could not answer searching the web (didn't find it) is: how can I achieve the so called "one-...
MacMartin's user avatar
  • 2,944
15 votes
2 answers

How can I get the amount of available memory portably across distributions?

The standard files/tools that report memory seem to have different formats on different Linux distributions. For example, on Arch and Ubuntu. Arch $ free total used free ...
terdon's user avatar
  • 242k
347 votes
27 answers

How can I get my external IP address in a shell script?

I need to find my external IP address from a shell script. At the moment I use this function: myip () { lwp-request -o text | awk '{ print $NF }' } But it relies on perl-libwww,...
Eugene Yarmash's user avatar
27 votes
6 answers

Output traffic on different interfaces based on destination port

My question is basically the same as Only allow certain outbound traffic on certain interfaces. I have two interfaces eth1 ( and wlan0 ( My default route is for eth1. Let's say ...
rumpel's user avatar
  • 374
182 votes
3 answers

Linux: Difference between /dev/console, /dev/tty and /dev/tty0

On a Linux system, what is the difference between /dev/console, /dev/tty and /dev/tty0? What are their respective uses, and how do they compare?
Axel Fontaine's user avatar
60 votes
3 answers

unix, difference between path starting with '/' and '//' [duplicate]

In unix/linux, any number of consecutive forwardslashes in a path is generally equivalent to a single forwardslash. eg. $ cd /home/shum $ pwd /home/shum $ cd /home//shum $ pwd /home/shum $ cd /home///...
Shum's user avatar
  • 1,355
18 votes
4 answers

32-bit, 64-bit CPU op-mode on Linux

I'm confused. Running Fedora Linux, lscpu yields: Architecture: i686 CPU op-mode(s): 32-bit, 64-bit ... But when I try to install a 64-bit program (Chrome) I get error like: ...
Zak's user avatar
  • 283
170 votes
5 answers

Why is my ethernet interface called enp0s10 instead of eth0?

When I run ifconfig -a, I only get lo and enp0s10 interfaces, not the classical eth0 What does enp0s10 mean? Why is there no eth0?
Nico Rodsevich's user avatar
73 votes
3 answers

Understanding /dev and its subdirs and files

$ ls -l /dev/stdin /dev/fd/0 lrwx------ 1 tim tim 64 2011-08-07 09:53 /dev/fd/0 -> /dev/pts/2 lrwxrwxrwx 1 root root 15 2011-08-06 08:14 /dev/stdin -> /proc/self/fd/0 $ ls -l /dev/pts/2 /proc/...
Tim's user avatar
  • 102k
64 votes
3 answers

Access to original contents of mount point

On my headless NAS I have sdf1 (a flash-card) mounted as / while /home is mounted from lv00 (an LVM volume backed by a software RAID). To be able to access the machine when the RAID fails, I have a ...
Janus's user avatar
  • 1,533
57 votes
3 answers

sending text input to a detached screen

I'm trying to run a minecraft server on my unRAID server. The server will run in the shell, and then sit there waiting for input. To stop it, I need to type 'stop' and press enter, and then it'll ...
richard plumb's user avatar
45 votes
8 answers

determine shell in script during runtime

As per my knowledge, to determine the current shell we use echo $0 in the shell. Rather I want my script to check in which shell it is running. So, I tried to print $0 in the script and it returns the ...
g4ur4v's user avatar
  • 1,764
33 votes
5 answers

How to use /dev/fb0 as a console from userspace, or output text to it

So I have a Palm Pre (original P100EWW) model that I enabled developer mode on, and installed a Debian Squeeze chroot. Works great. I have plans to use this for ANYTHING (bittorrent peer, web server)...
LawrenceC's user avatar
  • 11k
32 votes
3 answers

Can a bash script be hooked to a file?

I want a script to sleep unless a certain file is modifed/deleted (or a file created in a certain directory, or ...). Can this be achieved in some elegant way? The simplest thing that comes to my mind ...
Tobias Kienzler's user avatar
16 votes
3 answers

real memory usage

if I understand correctly, in the following output produced by free, 3535m is the actual free memory available to applications, only 413m is used, is this correct? need some clarification on the ...
user avatar
125 votes
3 answers

SSH login with clear text password as a parameter? [duplicate]

I need to login to a user that I've created on a remote host running Ubuntu. I can't use an ssh key because the ssh login will happen from a bash script ran within a server that I won't have access to ...
mmla's user avatar
  • 1,377
40 votes
4 answers

Why does dd from /dev/random give different file sizes?

I am running the following command on an ubuntu system: dd if=/dev/random of=rand bs=1K count=2 However, every time I run it, I end up with a file of a different size. Why is this? How can I ...
Daniel's user avatar
  • 1,167
11 votes
2 answers

Why were "USB-stick stall" problems reported in 2013? Why wasn't this problem solved by the existing "No-I/O dirty throttling" code?

The pernicious USB-stick stall problem -, November 2013. Artem S. Tashkinov recently encountered a problem that will be familiar to at least some LWN readers. Plug a slow storage device (a USB ...
sourcejedi's user avatar
  • 50.4k
216 votes
4 answers

Why do we use su - and not just su?

I don't understand why su - is preferred over su to login as root.
Dharmit's user avatar
  • 4,310
84 votes
12 answers

How to run a script on screen lock/unlock?

I'd like to run a script if the Gnome session is locked and unlocked. Is there a way that I can intercept this and perform certain actions when the desktop is locked or unlocked?
Naftuli Kay's user avatar
  • 39.7k
79 votes
9 answers

Correctly determining memory usage in Linux

I'm a bit confused on some of the results I am seeing from ps and free. On my server, this is the result of free -m [root@server ~]# free -m total used free shared ...
GoldenNewby's user avatar
60 votes
2 answers

Run a command for a specified time and then abort if time exceeds

I want know how I can run a command for a specified time say, one minute and if it doesn't complete execution then I should be able to stop it.
nikhil's user avatar
  • 1,012
43 votes
2 answers

How to make tr aware of non-ascii(unicode) characters?

I'm trying to remove some characters from file(UTF-8). I'm using tr for this purpose: tr -cs '[[:alpha:][:space:]]' ' ' <testdata.dat File contains some foreign characters (like "Латвийская" or "...
MatthewRock's user avatar
  • 6,986
41 votes
4 answers

What file systems on Linux store the creation time?

Are there any (good known, reliable) file systems on Linux that store the creation time of files and directories in the i-node table? If there are, is the "changed" time replaced by the creation ...
franziskus's user avatar
20 votes
2 answers

What should I do to force the root filesystem check (and optionally a fix) at boot?

Yesterday, one of our computers dropped to grub shell or honestly, I am unsure what shell it was when we turned on the machine. It showed that it can't mount the root filesystem or something in this ...
Vlastimil Burián's user avatar
10 votes
1 answer

How to change the forgotten root password?

I forgot my root password...actually I think I know what it is because it is the same password I have for pretty much everything but in the Terminal in tell me "Sorry, try again." Is there a way to ...
cherry_red's user avatar
271 votes
6 answers

What do the flags in /proc/cpuinfo mean?

How can I tell whether my processor has a particular feature? (64-bit instruction set, hardware-assisted virtualization, cryptographic accelerators, etc.) I know that the file /proc/cpuinfo contains ...
Gilles 'SO- stop being evil''s user avatar
113 votes
4 answers

What is meant by mounting a device in Linux?

I've heard the term "mounting" when referring to devices in Linux. What is its actual meaning? How it handling now unlike older versions? I haven't done that manually via the command-line. Can you ...
Renjith G's user avatar
  • 5,908
50 votes
4 answers

How can I set the processor affinity of a process on Linux?

How can I set the processor affinity of a process on Linux?
chillitom's user avatar
  • 653
33 votes
2 answers

What mount points exist on a typical Linux system?

I have 2 questions. During Linux installation we specify memory space for 2 mount points - root and swap. Are there any other mount points created without the users notice? Is this statement correct:...
John Eipe's user avatar
  • 673
162 votes
1 answer

How is Mono magical?

I'm learning C#, so I made a little C# program that says Hello, World!, then compiled it with mono-csc and ran it with mono: $ mono-csc Hello.cs $ mono Hello.exe Hello, World! I noticed that when I ...
cat's user avatar
  • 3,468

2 3 4 5