54
votes
3answers
29k views

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 ...
57
votes
9answers
2k views

Remember a half-typed command while I check something

I often find myself in the following position: I've started typing a long command at the bash prompt, but half-way through I find out I need to check something with another command. This is a problem ...
22
votes
5answers
14k views

SSH to decrypt encrypted LVM during headless server boot?

When I installed Ubuntu 10.04 and, now, 10.10, I was offered the option of enabling "encrypted LVM" for my hard drive. After choosing that option, I am prompted for my password during boot to decrypt ...
37
votes
6answers
6k views

The result of ls * , ls ** and ls ***

I know using the command ls will list all the directories. But what does the ls * command do ? I used it and it just lists the directories. Is the star in front of ls means how deep it can list the ...
23
votes
4answers
6k views

Measuring RAM usage of a program

time is a brilliant command if you want to figure out how much CPU time a given command takes. I am looking for something similar that can measure the max RAM usage of the program and any children. ...
19
votes
2answers
5k views

How do I tell I'm running in a chroot?

I have a unix installation that's supposed to be usable both as a chroot and as a standalone system. If it's running as a chroot, I don't want to run any service (cron, inetd, and so on), because they ...
19
votes
6answers
19k views

Lightweight outgoing SMTP server

What do you use as a lightweight SMTP for outgoing e-mails only? I am running an app that sends e-mails via SMTP when events occur once in a while, and I don't need a fully featured e-mail server. ...
18
votes
7answers
22k views

Which GUI diff viewer would you recommend, with Copy-to-Left/Right functionality?

I've hardly ever used anything other than Meld. Can you recommend anything else? It would be extra nice if you give a reason for your recommendation (as a Comment). [note] I want an alternative ...
14
votes
3answers
3k views

Reattach to lost X11 session

I'm using X11 forwarding over ssh to run Linux apps on my Windows box, and when the network drops it loses everything that was running. Is there anything similar to screen for X11?
12
votes
5answers
43k views

How can I read line by line from a variable in bash?

I have a variable which contains multiline output of a command. What's the most effecient way to read the output line by line from the variable? For example: jobs="$(jobs)" if [ "$jobs" ]; then ...
22
votes
8answers
20k views

Different ways to execute a shell script

There a several ways to execute a script, the ones I know are: /path/to/script # using the path (absolute or relative) . script # using the . (dot) source script # using the `source` command ...
13
votes
1answer
4k views

How can I configure a reverse SSH connection to the connecting computer?

I'm going to be deploying a number of machines in the near future which will be behind routers. It won't be feasible to set up dynamic DNS on each router and port forwarding, so is there a way I can ...
12
votes
5answers
12k views

Show only stderr on screen but write both stdout and stderr to file

How can I use BASH magic to achieve this? I want to only see stderr output on the screen, but I want both stdout and stderr to be written to a file. Clarification: I want both stdout and stderr to ...
22
votes
1answer
5k views

What does adduser do that useradd doesn't?

In addition to the more widespread useradd, Debian based systems also contain an additional adduser command which provides a higher level interface for adding users and some related tasks. There are ...
19
votes
3answers
7k views

How can I use two bash commands in -exec of find command?

Is it possible to use 2 commands in the -exec part of find command ? I've tried something like: find . -name "*" -exec chgrp -v new_group {} ; chmod -v 770 {} \; and I get: find: missing ...
14
votes
5answers
27k views

Script to monitor folder for new files?

How do I detect new files in a folder with a bash script? I would like to process the files as soon as they are created in the folder. Is this possible to do so or do I have to schedule a script with ...
15
votes
5answers
932 views

How to compile and install programs from source

This is an issue that really limits my enjoyment of Linux. If the application isn't on a repository or if it doesn't have an installer script, then I really struggle where and how to install an ...
33
votes
1answer
4k views

How to do a `tail -f` of log rotated files?

On a long running system I usually have a terminal with $ tail -f /var/log/kern.log or something like this open. But from time to time I have to restart such command because no new messages are ...
28
votes
2answers
26k views

How do I do a ls and then sort the results by date created?

In what order are the dated ordered by? Certainly not alphanumeric order. ls -lt sorts by modification time. But I need creation time.
20
votes
7answers
3k views

how to glob every hidden file except current and parent directory [duplicate]

I want to glob every hidden file and directory, but not the current (.) and parent directory (..). I am using bash. Observe current behaviour: $ ls -a . .. ...a ...aa ..a ..aa .a .aa .aaa ...
19
votes
5answers
4k views

Why is echo a shell built in command?

$ which echo echo: shell built-in command. $ which ls /bin/ls $ which cat /bin/cat Why is echo not an independent utility like ls, ps, cat etc? Why is it shell specific? Any good reasons?
14
votes
2answers
6k views

/proc/PID/fd/X link number

In Linux, in /proc/PID/fd/X, the links for file descriptors that are pipes or sockets have a number, like: l-wx------ 1 user user 64 Mar 24 00:05 1 -> pipe:[6839] l-wx------ 1 user user 64 Mar 24 ...
8
votes
1answer
905 views

Why is my bash prompt getting bugged when I browse the history?

Often when I start looking at history of commands some of the characters from a command displayed aren't erased, for example: What's happening: prompt$ some_command prompt$ some_commanother_command ...
21
votes
4answers
4k views

Single dashes `-` for single-character options, but double dashes `--` for words?

Where did the convention of using single dashes for letters and doubles dashes for words come from and why is continued to be used? For example if I type in ls --help, you see: -a, --all ...
14
votes
3answers
7k views

How to list files that were changed in a certain range of time?

How can I list recursively all files that were changed between 22.12.2011 and 24.12.2011?
12
votes
9answers
2k views

Detect init system using the shell

This may have more to do with detecting operating systems, but I specifically need the init system currently in use on the system. Fedora 15 now uses systemd, Ubuntu uses Upstart, while others use ...
10
votes
2answers
488 views

Order of redirections

I don't quite understand how the computer reads this command. cat file1 file2 1> file.txt 2>&1 If I understand, 2>&1 simply redirect Standard Error to Standard Output. By that ...
9
votes
1answer
274 views

Why my ethernet interface is called enp0s10 instead of eth0?

Just that, when I run ifconfig -a I only get lo and enp0s10 interfaces, not the classical eth0 What does enp0s10 means? Why is there no eth0?
6
votes
6answers
628 views

How can I reproduce commands run on one machine on another machine?

I would like to install some software on a linux-machine that I have run in VirtualBox. Then I would like to do the same thing on a linux-VPS. I think that I can save all commands that I run using ...
5
votes
3answers
5k views

Moved bin and other folders! How to get them back?

I accidentally moved all folders from root to a subfolder. (/bin, /etc, /home, /lib, /usr... all moved) The only ones that were not moved, since they were in use, are /bak, /boot, /dev, /proc, /sys. ...
3
votes
6answers
1k views

Common multiple SSH connections file handling issue

often I have to download a file that isn't directly accessable via the first SSH connection. For example I'm on a Windows machine and I want to access another machine that is only accessable from lan. ...
8
votes
1answer
329 views

Reliable way to jail child processes using `nsenter:`

I know that Linux namespaces, among many other things, can be leveraged to handle restricting and jailing child processes securely without any chance of their being zombied and dumped on init. But I'm ...
8
votes
3answers
230 views

How to define similar bash function at once

I have these functions in ~/.bashrc: function guard() { if [ -e 'Gemfile' ]; then bundle exec guard "$@" else command guard "$@" fi } function rspec() { if [ -e 'Gemfile' ]; ...
8
votes
6answers
8k views

Shell script for moving oldest files?

How do I write a script for moving just the 20 oldest files from one folder to another? Is there a way to grab the oldest files in a folder?
12
votes
2answers
832 views

Manipulating X key and pointer grabs on the command line

What command line tools exist to list and manage X server grabs? (That's grab as in key and pointer grabs, i.e. restricting the use of a particular key or mouse button to a particular application, or ...
9
votes
5answers
1k views

Why do I need to quote variable for if, but not for echo?

I've read that you need double quotes for expanding variables, e.g. if [ -n "$test" ]; then echo '$test ok'; else echo '$test null'; fi will work as expected, while if [ -n $test ]; then echo ...
8
votes
3answers
9k views

How do I know that my CPU supports 64bit operating systems under Linux?

How can I find out that my CPU supports 64bit operating systems under Linux, e.g.: Ubuntu, Fedora?
7
votes
3answers
26k views

Shell Script for logging into a ssh server

I tried writing a shell script which can do automatic login into a ssh server using password which is mentioned in the script. I have written the following code: set timeout 30 /usr/bin/ssh -p 8484 ...
7
votes
4answers
4k views

Make cd automatically ls

I find that I often do the following: %> cd bla/bla %> ls I would like it that whenever I cd into a directory it automatically does an ls. I fiddled with my .bashrc for a while, but couldn't ...
5
votes
2answers
615 views

Portability of file descriptor links

I've always wondered this but never took the time to find out, so I'll do so now - how portable is the usage shown here of either /proc/$$/fd/$N or /dev/fd/$N? I understand POSIX guarantees /dev/null, ...
10
votes
1answer
2k views

What does *~ mean?

At the end of a makefile I saw rm -f *~ *.class I understand the *.class, but what's *~?
6
votes
3answers
499 views

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 ...
4
votes
1answer
272 views

How to change the forgotten root password?

I am very new to Debian linux, 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, ...
2
votes
1answer
1k views

controlling priority of applications using cgroups

I would like to understand cgroups better and would like to understand the use-cases for applying cgroups. Are cgroups a good way for prioritizing different applications (i.e, giving higher priority ...
1
vote
2answers
3k views

df says I have 20G more disk space used than du. Why? [duplicate]

I used du to list all folders and sort by size, the results simply doesn't add up to how much disk space is used(using df). There's about 20G in discrepency, why? [root@xxx lib]# du --max-depth=1 -h ...
5
votes
1answer
159 views

How to allow to run su instantly after I added the user to the appropriate group

I have the su executable with the following permissions: bash-4.2# ls -la /bin/su -rws--s--- 1 root wheel 59930 Sep 14 2012 ./su When I am logged in as a user, not in the wheel group and try to ...
5
votes
3answers
368 views

When you type “ls -a”, what is the significance of “.” and “..”?

Whenever you type ls -a into the command prompt, you usually get all of your folders, files, and then you see that the first two entries are . and .. Just curious, but what is the significance of ...
5
votes
1answer
465 views

LoggedFS configuration file syntax

What is the syntax of the LoggedFS configuration file? The official documentation only had usage instructions for the loggedfs command and a configuration file example. Ok, it's XML, but what are ...
4
votes
2answers
2k views

CP: max source files number arguments for copy utility

Consider that there are countless number of files under /src/ cp /src/* /dst/ How many files cp will successfully process?
4
votes
2answers
522 views

`find` with multiple `-name` and `-exec` executes only the last matches of `-name`

When I'm using find . -type f -name "*.htm*" -o -name "*.js*" -o -name "*.txt" it finds all the types of file. But when I add -exec at the end: find . -type f -name "*.htm*" -o -name "*.js*" -o ...

15 30 50 per page