Posts

Showing posts from November, 2017

How to Keep Remote SSH Sessions and Processes Running After Disconnection [nohup]

We can use nohup and send a long running command to background. We can continue while the command will keep on executing in background. After that We can safely log out. With nohup command we tell the process to ignore the SIGHUP signal which is sent by ssh session on termination, thus making the command persist even after session logout. On session logout the command is detched from controlling terminal and keeps on running in background as daemon process. Here, is a simple scenario wherein, we have run find command to search for files in background on ssh session using nohup, after which the task was sent to background with prompt returning immediately giving PID and job ID of the process # nohup find / -type f > files_in_system.out 2>&1 & Resuming the session to view if job is still running When we re-login again, we can check the status of command, bring it back to foreground using 'fg jobID' to monitor its progress and so on. Below, the out...

Install curl & wget On FreeBSD

1.Run this command to Install curl. $ sudo pkg install curl Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 3 package(s) will be affected (of 0 checked): New packages to be INSTALLED: curl: 7.56.1 libnghttp2: 1.26.0 ca_root_nss: 3.32.1 Number of packages to be installed: 3 The process will require 5 MiB more space. 1 MiB to be downloaded. Proceed with this action? [y/N]: y [1/3] Fetching curl-7.56.1.txz: 100% 1 MiB 1.2MB/s 00:01 [2/3] Fetching libnghttp2-1.26.0.txz: 100% 104 KiB 106.3kB/s 00:01 Checking integrity... done (0 conflicting) [1/3] Installing libnghttp2-1.26.0... [1/3] Extracting libnghttp2-1.26.0: 100% [2/3] Installing ca_root_nss-3.32.1... Extracting ca_root_nss-3.32.1: 100% [1/3] Installing curl-7.56.1... [1/3] Extracting curl-7.56.1: 100% Message from ca_root_nss-3.32.1: ********************************* WARNING ********************************* FreeBSD doe...

FreeBSD: Install & Config Samba

1.At first update the server’s repository information. $ sudo pkg update 2.Search Samba in PKG. $ pkg search samba 3.Install the last version Samba. $ sudo pkg install samba46 Sample Output: Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 33 package(s) will be affected (of 0 checked): New packages to be INSTALLED: samba46: 4.6.8 libsunacl: 1.0 gnutls: 3.5.15 trousers: 0.3.14_1 tpm-emulator: 0.7.4_2 gmp: 6.1.2 p11-kit: 0.23.8 libtasn1: 4.12 ca_root_nss: 3.32.1 libffi: 3.2.1_1 libiconv: 1.14_11 nettle: 3.3 libidn2: 2.0.4 libunistring: 0.9.7 openldap-client: 2.4.45 python27: 2.7.14 python2: 2_3 py27-dnspython: 1.15.0 py27-setuptools: 36.2.2 tevent: 0.9.31 talloc: 2.1.9 py27-iso8601: 0.1.11 popt: 1.16_2 libinotify: 20170711_1 gamin: 0.1.10_9 glib: 2.50.2_6,1 pcre: 8.40_1 tdb: 1.3.12,1 ldb: 1.1.29_1 libarchive: 3.3.1,1 expat: 2.2.1 lzo2: 2.10_1 liblz4: 1.8.0,1 Number of...

FreeBSD: Install PostgreSQL Server & Client

1.At first update the server’s repository information. $ sudo pkg update 2.Search PostgreSQL in PKG. $ pkg search postgresql 3.Install the last version PostgreSQL. $ sudo pkg install postgresql10-server Sample Output: Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 5 package(s) will be affected (of 0 checked): New packages to be INSTALLED: postgresql10-server: 10.1 libxml2: 2.9.4 postgresql10-client: 10.1 perl5: 5.24.3 readline: 7.0.3 Number of packages to be installed: 5 The process will require 88 MiB more space. 21 MiB to be downloaded. Proceed with this action? [y/N]: y [1/5] Fetching postgresql10-server-10.1.txz: 100% 4 MiB 4.1MB/s 00:01 [2/5] Fetching libxml2-2.9.4.txz: 100% 802 KiB 820.8kB/s 00:01 [3/5] Fetching postgresql10-client-10.1.txz: 100% 2 MiB 2.6MB/s 00:01 [4/5] Fetching perl5-5.24.3.txz: 100% 13 MiB 14.0MB/s 00:01 [5/5] Fetching readlin...

FreeBSD: Update/Upgrade

config file: /etc/freebsd-update.conf 1.Run this command to update FreeBSD. # freebsd-update fetch # freebsd-update install daily update job: /etc/crobntab @daily root freebsd-update cron 2.Run this command to Uninstalling updates. # freebsd-update rollback 3.Run this command to Upgrade. # freebsd-update -r xx.x-RELEASE upgrade # freebsd-update install

FreeBSD: Install sudo Command, Allow wheel Group Users To Execute A Command As The Root [Without a Password]

1.Update the pkg tool # pkg update 2.Install sudo # pkg install sudo 3.Run 'visudo' command to configure sudo. # visudo 4.Uncomment to Allow members of group wheel to execute any command. # %wheel ALL=(ALL) ALL 5.Uncomment to Allow members of group wheel to execute any command without a password. # %wheel ALL=(ALL) NOPASSWD: ALL 6.Save and close the file.

How To Configure SSH Key-Based Authentication on a FreeBSD Server

1.In your local computer's terminal, generate a key pair with this command. $ ssh-keygen -t rsa -C "user@server" -b 4096 -f ~/.ssh/filename 2.Copy the public key to your server. $ ssh-copy-id -i ~/.ssh/filename[.pub] user@server If ssh-copy-id is not available on your machine , you will need to do this by hand. Copy the contents of filename.pub to ~/.ssh/authorized_keys $ cat .ssh/id_rsa.pub | ssh user@server 'cat >> .ssh/authorized_keys' $ ssh user@server "chmod 700 .ssh; chmod 640 .ssh/authorized_keys" [OR] $ scp ~/.ssh/id_rsa.pub user@server:~ $ mkdir -p ~/.ssh $ touch ~/.ssh/authorized_keys $ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys $ rm ~/id_rsa.pub $ chmod 600 ~/.ssh/authorized_keys $ chmod 700 ~/.ssh 3.In your server, To confirm the public key has been copied. $ cat ~/.ssh/authorized_keys 4.Backup the /etc/ssh/sshd_config file. $ cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak 5.Edit the /etc/ssh/sshd_config file....

The Simplest Way to Monitor CPU Temperature in FreeBSD

Load kernel module.(need root permissions). 'coretemp' for Intel series CPU. 'amdtemp' for AMD series CPU. # kldload coretemp Type these words, the temperature will be displayed. # sysctl dev.cpu | grep temperature Unload kernel module. # kldunload coretemp

How to Wipe Your Mac and Reinstall macOS

Create a backup Sign out of iTunes Open iTunes. From the menu bar at the top of your computer screen or at the top of the iTunes window, choose Account > Authorizations > Deauthorize This Computer. When prompted, enter your Apple ID and password. Then click Deauthorize. Sign out of iCloud Choose Apple (Apple) menu > System Preferences, click iCloud, and then click the Sign Out button. A dialog asks whether you want to keep a copy of your iCloud data on the Mac. Because you'll reformat the hard drive in a later step, just click Keep a Copy to proceed. After you sign out of iCloud, your iCloud data remains in iCloud and on any other devices you've signed into with your Apple ID. Sign out of iMessage If you're using OS X Mountain Lion or later, sign out of iMessage. In the Messages app, choose Messages > Preferences, then click Accounts. Select your iMessage account, then click Sign Out. If you're keeping paired Bluetooth devices, unpair them (op...