21
votes
7answers
6k views

How to understand what's taking up space?

I'm looking for a linux alternative to WinDirStat. I would like to know what is taking up space on my hard drives. A program that works on console and doesn't require a UI is preferred .
15
votes
6answers
2k views

Any way to sync directory structure when the files are already on both sides?

I have two drives with the same files, but the directory structure is totally different. Is there any way to 'move' all the files on the destination side so that they match the structure of the ...
5
votes
3answers
5k views

Storing output of command in shell variable

I have an operation using cut that I would like to assign result to a variable var4=echo ztemp.xml |cut -f1 -d '.' I get the error: ztemp.xml is not a command The value of var4 never gets ...
6
votes
5answers
1k views

How to clean up file extensions?

I have a directories with .MP3 files which I'd like to change the extensions to .mp3. What's the easiest way to do this? I'm think something along the lines of: find /RootPath -type f -iname "*.mp3" ...
5
votes
2answers
2k views

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

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 ...
5
votes
2answers
3k views

How can I rename a lot of files using a regex?

I want to rename a lot of files on Mac OS X (10.7.2).. I don't have the perl package for the rename command. My files have names like "T452-102456-0.png" and I want to delete the "-0" part. I know I ...
278
votes
7answers
24k views

Understanding the Linux kernel source

I am trying to understand how a function, say mkdir, works by looking at the kernel source. This is an attempt to understand the kernel internals and navigate between various functions. I know mkdir ...
81
votes
13answers
29k views

How to have tail -f show colored output

I'd like to be able to tail the output of a server log file that has messages like: INFO SEVERE etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I ...
91
votes
2answers
40k views

How to unfreeze after accidentally pressing Ctrl-S in a terminal?

It's a situation that has happened quite often to me: after I press (with a different intention) Ctrl-S in a terminal, the interaction (input or output) with it is frozen. It's probably a kind of ...
57
votes
5answers
116k views

How to forward X over SSH from Ubuntu machine?

I have a machine running Ubuntu which I SSH to from my Fedora 14 machine. I want to forward X from the Ubuntu machine back to Fedora so I can run graphical programs remotely. Both machines are on a ...
74
votes
2answers
9k views

Why do we use su - and not just su?

I don't understand why su - is preferred over su to login as root.
95
votes
8answers
8k views

The myths about malware in unix/linux

Is it possible for my Linux box to become infected with a malware? I haven't heard of it happening to anyone I know, and I've heard quite a few times that it isn't possible. Is that true? If so, ...
49
votes
6answers
1k views

Resources for portable shell programming

What resources exist for portable shell programming? The ultimate answer is to test on all targeted platforms, but that's rarely practical. The POSIX / Single UNIX specification is a start, but it ...
39
votes
5answers
26k views

What is a Superblock, Inode, Dentry and a File?

From the article Anatomy of Linux File Systems by Tim Jones, I read that Linux views all the file systems from the perspective of a common set of objects and these objects are superblock, inode, ...
41
votes
6answers
14k views

How can I move files and view the progress (e.g. with a progress bar)?

When moving large directories using mv, is there a way to view the progress (%)? The cp command on gentoo had a -g switch that showed the progress.
75
votes
6answers
6k views

Why is cd not a program?

I've always wondered why cd isn't a program, but never managed to find the answer. Anyone know why this is the case?
31
votes
5answers
5k views

Timing out in a shell script

I have a shell script that's reading from standard input. In rare circumstances, there will be no one ready to provide input, and the script must time out. In case of timeout, the script must execute ...
29
votes
4answers
2k views

Using '.' to execute files in bash

What's the difference between executing a script like this: ./test.sh and executing a script like this: . test.sh? I tried a simple, two-line script to see if I could find if there was a ...
46
votes
6answers
15k views

Can I create a user-specific hosts file to complement /etc/hosts?

Is it possible to add a list of hosts that are only specific to a certain user? Perhaps a user-specific hosts file? This mechanism should also complement the entries in the /etc/hosts file.
8
votes
1answer
6k views

File descriptors & shell scripting

I am having a very hard time understanding how does one use file descriptors in shell scripts. I know the basics such as exec 5 > /tmp/foo So fd 5 is attached to foo for writing. exec 6 < ...
21
votes
3answers
16k views

Installing Grub 2 on a USB flash drive

MultiBootISOs is a tool that let you install Grub on a USB flash drive. I really like it because it lets me boot from ISO files and let me put a bunch of ISOs on my USB and choose which one to boot. ...
12
votes
1answer
2k views

Can one PC be used by two users at the same time via dual-monitor?

Since modern PCs can use two screens at the same time I wonder if it is possible to plug in two keyboards and mouses as well to have the two screens run two (more or less) independent X-sessions at ...
8
votes
3answers
530 views

Trapping errors in command substitution using “-o errtrace” (ie set -E)

According to this ref manual: -E (also -o errtrace) If set, any trap on ERR is inherited by shell functions, command substitutions, and commands executed in a subshell environment. The ERR ...
12
votes
2answers
5k views

Debian based system, only one gui program, nothing else

I would like to make a debian system where you can only open one GUI program at boot, no other graphical interface, no minimize, or any X apart from that program, is there a way to do it on debian if ...
11
votes
3answers
6k views

How to find out which (not installed) package a file belongs to?

On Debian systems (and derivatives): $ dpkg --search /bin/ls coreutils: /bin/ls That is, the file /bin/ls belongs to the Debian package named coreutils. But this only works if the package is ...
7
votes
2answers
2k views

Find filesystem of an unmounted partition from a script

I'm writing a custom automated install using AIF (Arch Installation Framework), and I need to find the filesystem on a partition given a partition. So far I have this: grok_partitions () { local ...
7
votes
2answers
8k views

Extracting a regex matched with 'sed' without printing the surrounding characters

To all the 'sed' doctors out there: I have a seemingly trivial 'sed' question to which I have not been able to find a solution. How can you get 'sed' to exctract a regular expression it has matched ...
7
votes
2answers
4k views

ssh port forward to access my home machine from anywhere

http://serverfault.com/questions/303937/how-to-make-freebsd-box-accessible-from-internet I want to understand this whole process of port forwarding. I read so many things but failing to understand ...
3
votes
4answers
13k views

Changing extension to multiple files

I would like to change file extension from *.txt file to *.text file, tried using the basename command, but I am having trouble on changing more than 1 file, I am getting a basename: too many ...
12
votes
3answers
3k views

Does (should) LC_COLLATE affect character ranges?

Collation order through LC_COLLATE defines not only the sort order of individual characters, but also the meaning of character ranges. Or does it? Consider the following snippet: unset LANGUAGE ...
6
votes
3answers
3k views

Can't access select https sites on Linux over PPPoE

My internet connection used to be a direct LAN connection to my provider. Back then, everything would load fine on both Windows and Ubuntu (dual boot). However, a while ago they started needing me to ...
4
votes
2answers
756 views

undelete files from local fileserver

I have a NAS (mybook world white light) in my living room where all my music and stuff is stored. I've mounted the music folder of the nas in the local music folder of my home directory on my desktop ...
215
votes
9answers
96k views

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 ...
120
votes
1answer
22k views

Difference between nohup, disown and &

What is the difference between $ nohup foo and $ foo & and $ foo & $ disown
80
votes
7answers
11k views

Which is the safest way to get root privileges: sudo, su or login?

I would like to have the root account in safety even if my unprivileged user is compromised. On Ubuntu you can only use sudo for "security reasons" by default. However I am not sure it is any safer ...
42
votes
11answers
13k views

Recommended reading to better understand Unix/Linux internals [closed]

I've worked on *nix environments for the last four years as a application developer (mostly in C). Please suggest some books/blogs etc. for improving my *nix internals knowledge.
55
votes
2answers
30k views

Getting 256 colors to work in tmux

I have 256 colors working just fine in konsole,. I thought I'd give tmux a try because, unlike screen, it seems to support vi mode. However I find that the colors of my prompt show up and this is ...
27
votes
10answers
12k views

Correct locking in shell scripts?

Sometimes you have to make sure that only one instance of a shell script is running at the same time. For example a cron job which is executed via crond that does not provide locking on its own (e.g. ...
25
votes
1answer
948 views

Why does my regular expression work in X but not in Y?

I wrote a regular expression which works well in a certain program (grep, sed, awk, perl, python, ruby, ksh, bash, zsh, find, emacs, vi, vim, gedit, …). But when I use it in a different program (or on ...
27
votes
4answers
2k views

Is there a one-liner that allows me to create a directory and move into it at the same time?

I find myself repeating a lot of: mkdir longtitleproject cd longtitleproject Is there a way of doing it in one line without repeating the directory name? I'm on bash here.
43
votes
2answers
11k views

Why is there a big delay after entering a wrong password?

I notice a weird (well, according to me) thing about passwords. For example, if I type an incorrect password during login, there will be a few seconds' delay before the system tells me so. When I try ...
25
votes
6answers
18k views

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 ...
23
votes
6answers
5k views

What Unix commands can be used as a semaphore/lock?

I want to run multiple Bash shell scripts in parallel. However, I want to avoid race conditions. What Unix commands are truly atomic that I could use for this purpose, and how can I use them?
8
votes
2answers
12k views

How to install program locally without sudo privileges?

Assume I have ssh access to some Ubuntu server as user and I need some not system tools to be installed for convenience (mc, rtorrent, mcedit). I do not want to bother admins for these small programs. ...
26
votes
5answers
17k views

How to speed my too-slow ssh login?

Running ssh user@hostname takes ~30s. Here's the scenario: this is a VM on the local LAN Windows and Mac machines get instant login am using Debian and I could reproduce with an Ubuntu machine ...
13
votes
5answers
2k views

Getting information on a machine's hardware in Linux

How can I check what hardware I have? (With BIOS version etc.)
11
votes
2answers
2k views

Correctly setting environment

I'm using zsh and gdm to run gnome. Some time ago I discovered that variables are not set correctly. For example LANG/LC_ALL are incorrect ("" instead of en_GB.UTF-8). I split the .zshrc into .zshrc ...
7
votes
8answers
6k views

Automatically run commands over SSH on many servers

There is a list of IP addresses in a .txt file, ex.: 1.1.1.1 2.2.2.2 3.3.3.3 Behind every IP address there is a server, and on every server there is an sshd running on port 22. Not every server is ...
25
votes
4answers
5k views

Is Mac OS X UNIX?

I have this argument recently saying Mac OS X was not UNIX, but Unix-like. I know there is a Single Unix Specification and those spec complaint could use the UNIX trade mark. Is Mac OS X an UNIX ...

15 30 50 per page