Home
Losers Wiki
Cancel

run-script-as-different-user

To run as a different user that may not have a login shell use; su -c SCRIPT -s /bin/sh USER eg; su -c /home/nginx/html/youtube/youtube_downloader.sh -s /bin/bash www-data

run-command-as-different-user

su - username -s shell -c "command" eg; su - www-data -s /bin/bash -c "/usr/bin/youtube-downloader.sh"

ruby

| install cheatsheet - worked on Centos 6

robocopy

on a Windows server, Robocopy can be used to simply back local data up to a remote share; Place the following in a batch file and schedule to run via windows task scheduler: @ECHO OFF SETLOCAL SE...

returning-a-comma-delimited-list-of-values

use a function: CREATE FUNCTION [dbo].[fnAreas]( @candidate_id int ) RETURNS varchar(max) AS BEGIN -- returns a comma-delimited list of areas for a given candidate_id DECLARE @Areas varchar(max)...

return-comma-separated-list

usethe coalecse function in sql server eg. get a list of those db’s with recovery model full for use in auto-backup function for trans logs DECLARE @commalist varchar(max) SELECT @commalist = co...

replacing-comma-with-newline

use the ‘\r’ combo instead of ‘\n’ hostname,hostalias,hostaddress,hoststate :%s/,/\r/g hostname hostalias hostaddress hoststate To go back the other way, use ‘\n’ instead of ‘\r’..weird :%s/\n/...

removing-ssh-keys-from-keyring

on xubuntu the keyring program is called seahorse. run that from a terminal and you’ll be able to select which keys to forget.

removing-hidden-files

find the inum of it via ls -il; root@server:/export/home/operator:> ls -il total 217     176546 -rw-r--r--   1 root     root         205 Nov 22 09:22      234262 -rwxr--r--   1 root     root   ...

remove-whitespace

In a search, \s finds whitespace (a space or a tab), and \+ finds one or more occurrences. This removes whitespace from the end of the line :%s/\s\+$// This removes from the start of the line :...