Tag Info

Hot answers tagged

31

And now, the systemd answer. You're using, per the tag on your question, Red Hat Enterprise Linux. Since version 7, that has used systemd. None of the other answers are correct for the world of systemd; nor even are some of the assumptions in your question. Forget about runlevels; they exist, but only as compatibility shims. The systemd documentation ...


16

halt instructs the hardware to stop all CPU functions, but leaves it in a powered-on state. This usually means someone has to reboot or shut the machine down manually by pressing the power button afterwards. The specific way to achieve this is architecture specific, but for instance the x86 instruction set provides the HLT instructions which halts the ...


11

The init process is always assigned PID 1. The /proc filesystem provides a way to obtain the path to an executable given a PID. In other words: nathan@nathan-desktop:~$ sudo stat /proc/1/exe File: '/proc/1/exe' -> '/sbin/upstart' As you can see, the init process on my Ubuntu 14.10 box is Upstart. Ubuntu 15.04 uses systemd, so running that command ...


9

It might help to up /proc/sys/vm/page-cluster (default: 3). From the kernel documentation (sysctl/vm.txt): page-cluster page-cluster controls the number of pages up to which consecutive pages are read in from swap in a single attempt. This is the swap counterpart to page cache readahead. The mentioned consecutivity is not in terms of ...


8

On RPM-based systems, you can query the RPM database to see what package provides /sbin/init. For example: fedora:~$ rpm -qf /sbin/init systemd-216-24.fc21.x86_64 centos:~$ rpm -qf /sbin/init upstart-0.6.5-12.el6_4.1.x86_64 opensuse:~$ rpm -qf /sbin/init systemd-sysvinit-44-10.1.1.i586 If you just want the package name, and not version, you could add ...


7

As written in the manual page, the /etc/networks file is to describe symbolic names for networks. With network, it is meant the network address with tailing .0 at the end. Only simple Class A, B or C networks are supported. In your example the google-dns entry is wrong. It's not a A,B or C network. It's an ip-address-hostname-relationship therefore it ...


4

You can poke around the system to find indicators. One way is to check for the existence of three directories: /usr/lib/systemd tells you you're on a systemd based system. /usr/share/upstart is a pretty good indicator that you're on an Upstart-based system. /etc/init.d tells you the box has SysV init in its history The thing is, these are heuristics that ...


4

This is actually quite a difficult problem. One of the major difficulties is that the places where one most often wants to do this are the places where it's quite likely that one will be in the middle of installing or changing stuff. Another is that there's a subtle but very important difference between the system management toolset that is installed, the ...


4

You may try adding the programs you most care about to a cgroup and tuning swappiness so that the next time the application runs the programs you add are less likely to be candidates for swapping. Some of their pages will likely still be swapped out but it may get around your performance problems. A large part of it is probably just the "stop and start" ...


3

Use convert to do the job. convert -resize "1024x768>" origIMG destIMG will resize origIMG to 1024x768 keeping aspect ratio and resizing only if image is greater than 1024, storing the new image in destIMG. After that you can move the destIMG to the original. Use a loop to travel through all your directories or use find.


3

There is no way to achieve this within a script - scripts start subshell, which is a standalone environment. There's all sorts of reasons for this, but pretty fundamentally - a script cannot tamper with your environment (including your cwd). The closest you get is creating an alias within the current shell. alias chr="cd /" Either that, or 'source' the ...


3

It seems to me that you can't magically "make the system responsive again". You either incur the penalty or reading pages back from swap space into memory now or you incur it later, but one way or the other you incur it. Indeed, if you do something like swapoff -a && swapon -a then you may feel more pain rather than less, because you force some pages ...


3

Answering my own question... In fact it is possible to remove directory from the remote server completely (including directory itself). Check the example below: rsync -r --delete --include 'x/***' --exclude '*' local_empty_directory/ rsync://some_server/some_share/x_parent_directory The key is to clean the parent directory for x (x_parent_directory in ...


2

This is a known error in Samsung SSDs. The drives do not properly implement queued trim commands. However, Ubuntu (and probably most other Linux distributions) now implement trim as a cronjob to improve performance, so this is not of any concern. For more details, see the kernel bug on this: https://bugzilla.kernel.org/show_bug.cgi?id=72341 The reason it ...


2

You can do something like: ln -s /bin/ksh /usr/bin/ksh P.S. ln -s /bin/ksh /usr/bin will work fine as ln command replicate the filename (basename) if second argument is directory


2

ImageMagick tools convert or mogrify will do the job. You can get them via your package manager or the source/rpms here: http://www.imagemagick.org/script/binary-releases.php#unix Basic usage: $ mogrify -resize 820x *.jpg If you need recursion: find . -name '*.jpg' -execdir mogrify -resize 820x {} \;


2

halt, poweroff and shutdown -h are completely equivalent. In fact, halt and poweroff do nothing but call shutdown -h. From the halt/poweroff manpage: If halt or reboot is called when the system is not in runlevel 0 or 6, in other words when it's running normally, shutdown will be invoked instead (with the -h or -r flag). For more info see the shutdown(8) ...


2

That seems like a DDoS trojan. Mostly those trojans are in cronjobs. Stop the cron daemon and check your /etc/crontab and /etc/cron.* files for multiple cronjobs that create those files.


2

The ip command never uses a host name for input either, so your example is hardly relevant. Also you've put a host name into /etc/networks, not a network name! Entries from /etc/networks are used by tools that try to convert numbers to names, e.g. the (deprecated) route command. Without a suitable entry it shows: # route Kernel IP routing table Destination ...


2

Yes, awk is the right tool for such tasks. Assuming all data is in one file as shown in the question, try: awk ' /^Organism:/ { prefix = $2 ; print ; next } /^matching/ || !NF { print ; next } { print prefix, $1 } '


2

hidepid is a mount option for procfs that hides processes from other users. There are three settings: hidepid=0: Anyone can read the world-readable files in /proc/PID hidepid=1: Users can only access the /proc/PID directories and files that belong to their user. hidepid=2: The same as hidepid=1, but the processes of other users will not even be visible in ...


2

I don't know if this is the kosher way to do it, but it does work: The program that runs on a virtual terminal at startup is decided by the /etc/inittab file. These are all run as root. It has lines like these: 1:2345:respawn:/sbin/getty 38400 tty1 They decide what ends up on which virtual terminal. /sbin/getty provides a virtual terminal. In my case, ...


1

On Root privileges You can remove root login, root password etc. You will then need some other way to get admin things done: such as adding users to groups configuring sudo to give fine-grained permissions giving users and programs capabilities. root has recently been broken into a number of capabilities, so where you read that you need root to do ...


1

If your shell supports it, you could use a here document to read the commands from standard input, with a quoted delimiter to prevent shell expansion of the awk variable $5 awk -f- somefile << "EOF" {sum+=$5} END { print "Average = ",sum/NR} EOF Or just put the commands in a file and run that with awk -f.


1

You don't need '' (strong quotes), you can use the weaker form "", except you then need to escape the "s. awk "{sum+=\$5} END { print \"Average = \",sum/NR}" But why?


1

Talked to the infrastructure people, and the answer is that there are extended ACLs in place that act differently based on location, and that they were erroneously set.


1

There's a fantastic pair of articles on LWN that describe how syscalls work on Linux: "Anatomy of a system call", part 1 and part 2.


1

Try ssh -f user@host '<your command here>'. From the ssh man page: -f Requests ssh to go to background just before command execution. This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background. For example, if i do ssh -f <my computer> 'echo "hello $(pstree -p | ...


1

An awk solution: awk '!a[$0]++'


1

No, there is not a way to do that. That would break the very concept behind separation of network namespaces. There is one and only one way to "escape" that separation, and it's veth interfaces. In a little bit more detail, it wouldn't just be a matter of somehow "sharing" a loopback interface between network namespaces. Each network namespace is logically ...



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