modify message of last unpushed commit

git commit --amend -m "New commit message"

create tag:

git tag -a MY_VERSION -m „my version 1.0-Release“
git push origin [tagname]

git tag - show all tags
git show MY_VERSION

change repository for pushes
git remote set-url origin ssh://<git@.../new_repository.git>
git push -u origin master

create new local branch
git checkout -b <branchName>

create new remote branch
1. create local branch
git checkout -b <branchName>

2. push local branch. origin = <remote>
git push origin <branchName>

3. set tracking information for this branch you can d
git branch --set-upstream-to=origin/<branchName> <branchName>

delete files and folders from repository but not from file system
git rm -r --cached target/*

delete .orig files
git clean -f

make visible new remote branch local
git pull

merge my branch with other branch
git merge <other_branch> --no-ff

--no-ff - create a merge commit even when the merge resolves as a fast-forward

merge conflicts
git mergetool

remove new local branch
git branch -d <branchName>

remove new local branch immediately
git branch -D <branchName>

revert added files
git reset HEAD <file>

show all branches (remote and local)
git branch -a

show local branches
git branch

show remote branches
git branch -r

System restart / reboot

 sudo systemctl reboot

Zip files in directory into its own archive

for file in your_file_name*; do zip ${file%}.zip $file; rm $file; done

Create a directory and sub directories

mkdir -p one/two/three/four

Get the size of a directory

du -sh file_path

  -s, --summarize
         display only a total for each argument

  -h, --human-readable
         print sizes in human readable format (e.g., 1K 234M 2G)

  -c, --total
         produce a grand total

Show last lines from a log file

tail -n 1000 /var/log/mail.log | more
  -n 100 = last 100 lines
  more = to be able to view file line by line

Download a file

wget <http://domane.to.file.zip> -P </path/to/folder>

Lock remote access for root user

vi /etc/ssh/sshd_config
change: "PermitRootLogin yes" -> "PermitRootLogin no"
/etc/init.d/ssh reload

Show all users (ubuntu)

cat /etc/passwd | cut -d":" -f1
(etc/shadow - users file)

Lock user for login

passwd <username> -l

unlock user for login

passwd <username> -u

Grant executing rights to the current user

chmod +x (datei)

Change folder or file owner

chown <newowner> -R /path/

-R recursive

Unpack tar-archive

tar xf [ARCHIV].tar
- x unpack
- f File

Create tar-archive

tar -cvzf /path/[ARCHIV].tgz /path/to/folde

Create a file

touch <filename>

Add user to the sudoers file

open Sudoers file (/etc/sudoers) and add:

...
# User privilege specification
<username>    ALL=(ALL:ALL) ALL

Install rpm file

sudo rpm -i <filename>.rpm

Delete file or folder

rm -rf <ordername>

delete all files in current folder

rm -rf *

-r - recursive
-f - force (delete without warnings)

show current directory

pwd

show which sub-folders spend how much disk space

du -h --max-depth=1 </folder> | sort -hr

-h, --human-readable           print sizes in human readable format

search all users without result limit and change a property of found users:


var myOrg = "230";
var group = people.getGroup("GROUP_Org_" + myOrg);

var scriptUsers = people.getMembers(group); 

for each(var scriptUser in scriptUsers) {
	if (scriptUser.properties.organizationId != myOrg) {
		logger.log(scriptUser.properties.organizationId);
		people.removeAuthority(group, scriptUser);
	}
}

search all users without result limit and change a property of found users:

var filterName = "*";
var paging =  utils.createPaging(-1, 0);
var sortBy = "userName";
 
var scriptUsers = groups.searchUsers(filterName, paging, sortBy);
logger.log("found:" + scriptUsers.length);

var j = 0;
//change a property of the user:
for each(var scriptUser in scriptUsers) {
    var p = scriptUser.person;
    if (p.properties["userStatus"] != "") {
        p.properties["userStatus"] = "";
        p.save();
        j = j+1;
    }
}
logger.log("### changed for users:" + j);
var context = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var policyBehaviourFilter = context.getBean('policyBehaviourFilter', Packages.org.alfresco.repo.policy.BehaviourFilter); 

...
var foundNode = search.findNode(nodeRef);
policyBehaviourFilter.disableBehaviour(nodeRef);
foundNode.remove();