Hot answers tagged

223

You can just use tar -cf myfile.tar /etc/dir1 /var/www/html /home/somedir also, you could use tar -czf myfile.tar.gz /etc/dir1 /var/www/html /home/somedir This second example (note the z in the -czf parameter) will compress the tar file using g(z)ip.


199

You can remove just the offending line from bash's history, instead of clearing the entire history. Simply remove the line with the -d flag, then save (write) the new history with the -w flag: $ history 351 ssh me@site.com 352 my_password $ history -d 352 $ history -w


153

The size of a directory as shown in your screenshot isn't the sum of the size of the contents, it is the size of the meta-data associated with the directory - file names, etc. https://unix.stackexchange.com/questions/55/what-does-size-of-a-directory-mean-in-output-of-ls-l-command To find out how much space the directory contents are using, you can use du ...


122

There are two parts to this: bash stores the history in a file ~/.bash_history which is, by default, written to at the end of the session the history that is kept in memory To be safe, you need to clear it from the session: history -c and truncate the history file as needed: > ~/.bash_history If your session in which you typed the password is still ...


93

As Gasim said: Add the following to /etc/sysconfig/network-scripts/ifcfg-enp0s3 DNS1=8.8.8.8 DNS2=8.8.4.4 # Note this was set to no ONBOOT=yes


60

$(command) is “command substitution”.  As you seem to understand, it runs the command, captures its output, and inserts that into the command line that contains the $(…); e.g., $ ls -ld $(date +%B).txt -rwxr-xr-x 1 Noob Noob 867 Jul 2 11:09 July.txt ${parameter} is “parameter substitution”.  A lot of information can be found in the shell’s man page, ...


52

CentOS sure keeps this information well hidden. Excerpts from this link: Various installation images are available for installing CentOS. Which image you need to download depends on your installation environment. All of these images can either be burned on a DVD or dd’ed to an USB memory stick. If you are unsure which image to use, pick the DVD ...


49

nmap does this easily: sudo nmap --script broadcast-dhcp-discover -e eth0 will show: Starting Nmap 6.40 ( http://nmap.org ) at 2016-08-16 09:25 UTC Pre-scan script results: | broadcast-dhcp-discover: | IP Offered: 192.168.0.67 | DHCP Message Type: DHCPOFFER | Server Identifier: 192.168.0.1 | IP Address Lease Time: 0 days, 0:05:00 | Subnet Mask: ...


47

You get a lot more information about the failure if you run sshfs as: sshfs -odebug,sshfs_debug,loglevel=debug user@host ... Usually this will give you something a lot more helpful to debug the problem.


43

Here is how to get devtoolset-2 (including gcc 4.8.1) This was taken from http://people.centos.org/tru/devtools-2/readme wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++ Known issues: unsigned packages CentOS-6 devtoolset-2 needs ...


40

To set the values at runtime, use sysctl. (I suppose one can write to /proc/sys/kernel/printk directly too and apparently you can also use dmesg -n CUR as described here) Display: # sysctl kernel.printk kernel.printk = 2 4 1 7 The separators in the output are single tabs, btw. Set. Here the separators are just spaces. Works as well. # ...


36

On CentOS login information is logged in /var/log/secure, not /var/logs/auth.log.


35

For one repo you can add the following in the repo configuration: sslverify=0 For all repos, you can add the following to "/etc/yum.conf": sslverify=false


34

I also work on CentOS 7, and had a similar issue: # systemctl unmask tmp.mount Failed to execute operation: Access denied The denial has to do with SELinux. This can be your case if you are running SELinux in enforcing mode: # getenforce Enforcing In my case, the systemctl error had produced an USER_AVC denial in SELinux log file, /var/log/audit/audit....


33

I've just ran into this and in my case it was caused by quoting a user name in my service file: [Unit] Description=Demonstrate Failed at step USER spawning ...: No such process error when user name is quoted [Service] User="tadeusz" ExecStart=/bin/echo hello [Install] WantedBy=multi-user.target Starting this service on Ubuntu 16.04.2 LTS (Amazon EC2 ...


29

There is new version of devtoolset 2.0. Nice people from Cern working on Scientific Linux created an open version: If you use CentOS (not Scientific Linux), then you will have to import their GPG key from here using: rpm --import http://www.scientificlinux.org/documentation/gpg/RPM-GPG-KEY-cern Enjoy!


27

You'll need a group with apache and all the VPS users in it, call it vpsusers for instance # do this as root groupadd vpsusers gpasswd -a apache vpsusers gpasswd -a bob vpsusers # if you have a user named bob gpasswd -a alice vpsusers # if you have a user name alice # etc... And then make that group the group owner of the directory in question, eg # ...


26

tail -n+3 outputs the last lines starting from the third one.


26

In my case, I had just upgraded systemd and any systemctl command was failing: # systemctl daemon-reexec Failed to reload daemon: Access denied # systemctl status Failed to read server status: Access denied However according to the init manpage, you can do the same thing by sending SIGTERM to the daemon running as PID 1, which worked: kill -TERM 1 This ...


24

CentOS 7 still uses the deprecated vga parameter. You wanted step-by-step, you get it: Make yourself root: sudo su vi /etc/default/grub In Vi, press i or Insert-key on your keyboard to enter the edit mode. Add vga=792 inside the "-quotes for GRUB_CMDLINE_LINUX, f.ex. GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet vga=792" Press Esc and type :wq and hit ...


24

You could boot with a live Linux CD and then mount the CentOS filesystem, and edit the .bashrc file from there.


23

Answer based on comments from @Zoredache: Command is smartctl --all /dev/sdc and the section to look under is "Vendor Specific SMART Attributes with Thresholds", which has an attribute named "Power_On_Hours". So command for just getting power on hours (runnning) is: smartctl --all /dev/sdc | grep Power_On_Hours Which can then show something like: 9 ...


23

Since bash (at least all historic and current versions I'm aware of) does not automatically save history until you exit, a generally applicable strategy when you have typed a command that you want to ensure never gets saved is to immediately type: kill -9 $$ This kills the shell with SIGKILL, which can't be caught, so the shell has no way to save anything ...


22

CentOS7 is using grub2 and the generated /boot/grub2/grub.cfg rather than the old grub.conf format, which is why you can't find it. The new grub.cfg file is not intended for direct editing, instead you need to modify the source files that are used to generate it. The files in question are /etc/default/grub and the scripts in /etc/grub.d/. In particular, ...


22

Based on the errors, you need to update the files to look like this: /etc/sysconfig/network-scripts/ifcfg-enp0s3: TYPE="Ethernet" BOOTPROTO="static" IPADDR=10.0.0.10 NETMASK=255.255.255.0 NM_CONTROLLED=no DEFROUTE="yes" PEERDNS="yes" PEERROUTES="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_PEERDNS="yes" ...


21

# 1. Install a package with repository for your system: # RHEL 6: `yum-config-manager --enable rhel-server-rhscl-6-rpmss` # RHEL 7: `yum-config-manager --enable rhel-server-rhscl-7-rpms` $ sudo yum install centos-release-scl # On CentOS 6/7+, install package centos-release-scl available in CentOS repository # 2. Install the collection: $ sudo yum install ...


21

A simple 1-liner should do (assumes Posix sh-compatible shell): for f in *:*; do mv -v "$f" $(echo "$f" | tr ':' '-'); done Explanation: for ... in ...; do ...; done is a loop *:* matches all files and directories in the the current directory which have : in their name f is assigned in turn to each such file name in the loop mv renames its first argument ...


21

You can control the delay time with a setting under "Power" option within Settings area.


21

For Ubuntu, try: How to install libOpenCL.so on Ubuntu sudo apt update sudo apt install ocl-icd-opencl-dev


21

You OS does not use systemd or systemctl but still uses init.d or service commands: Eg: sudo service {servicename} {stop|start|restart} Or /etc/init.d/{service} {stop|start|restart} Note that even on newer systems which use systemd, you can generally use the sudo service XYZ restartsyntax and it will still work.


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