sudo -u <user> bash -c "<command to execute>"
Background: I had previously SSH'd into a server and CD to directory /opt/foo when I got kicked out by network troubles. A colleague was trying to delete that directory and could not delete it.
who to get the active sessions.pts/N session from the list.ps -ef | grep -i sshd and from the list, locate the PID for the SSHD session that has pts/N.A repository of Git commands I find useful.
| [testng] org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (Original error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "D:\vish\adt-bundle\sdk\platform-tools\adb.exe shell "settings get global airplane_mode_on"" | |
| [testng] error: more than one device/emulator | |
| [testng] ) (WARNING: The server did not provide any stacktrace information) | |
| [testng] Command duration or timeout: 43 milliseconds | |
| [testng] Build info: version: 'unknown', revision: 'unknown', time: 'unknown' | |
| [testng] System info: host: 'freeman', ip: '10.0.0.119', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_25' | |
| [testng] Driver info: io.appium.java_client.android.AndroidDriver | |
| [testng] Capabilities [{appPackage=com.icelero.crunch, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=MotoE, uuid=ZX1B33GSLN, platform=LINUX, appActivity=app.CrunchSplashActivity, chromedriverExecutable=C:\Users\vish\AppData\Loca |
| 2016-03-10 11:58:34:740 - info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a) | |
| 2016-03-10 11:58:34:742 - info: Appium REST http interface listener started on 127.0.0.1:4723 | |
| 2016-03-10 11:58:34:745 - debug: Non-default server args: {"app":"D:\\vish\\ma-app-verification-android\\appium-projects\\AppiumAndroid\\CrunchAPKs\\Crunch.apk","udid":"ZX1B33GSLN","address":"127.0.0.1","log":"C:\\Users\\vish\\AppData\\Local\\Temp\\appium4723.log","loglevel":"warn:debug","localTimezone":true,"androidPackage":"com.icelero.crunch","androidWaitActivity":"app.CrunchSplashActivity","deviceName":"MotoE","platformName":"Android","platformVersion":"5.1","automationName":"Appium","chromeDriverPort":4725,"chromedriverExecutable":"C:\\Users\\vish\\AppData\\Local\\Temp\\\\chromedriver.exe","defaultCommandTimeout":600} | |
| 2016-03-10 11:58:34:745 - info: Console LogLevel: warn | |
| 2016-03-10 11:58:34:745 - info: File LogLevel: debug | |
| 2016-03-10 11:58:35:620 - info: --> GET /wd/hub/status {} | |
| 2016-03-10 11:58:35:622 - de |
| ###################################### | |
| # get and set network connection | |
| ###################################### | |
| # returns 1 if airplane mode is enabled, 0 otherwise. | |
| adb -s $DEVICE_ID shell settings get global airplane_mode_on | |
| # the same for wifi and mobile data. | |
| adb -s $DEVICE_ID shell settings get global wifi_on | |
| adb -s $DEVICE_ID shell settings get global mobile_data |
| #!/bin/bash | |
| set -e | |
| echo "==== rename.sh ===== | |
| This script recurses through videos in a folder, and | |
| renames them into a format as follows: | |
| test_[w]x[h]_[bitrate]_[duration].[extension] | |
| e.g. | |
| test_640x480_2973Kbps_34s.mov |
Dangling images are "no name, no tag" images <none>:<none> created during image building. These images are bad because they consume disk space.
Reference.
docker images -f "dangling=true"
| #!/bin/bash | |
| set -e | |
| ########### | |
| # AWS CLI Must be installed e.g using sudo apt install awscli. | |
| # This script cleans up your security group to remove old IP addresses from the rules for SSH, and | |
| # adds your current IP address. | |
| # This scenario is especially for cases where your ISP only allows dynamic IP addresses, or you | |
| # access AWS from multiple locations. |