Get help (close with q)
||cd --help||Also help|
|Tab (1x or 2x)||Auto completion|
|↑||See previous command|
|Ctrl+c||Kill the current process or command (e.g. if something hangs)|
|Ctrl+d||Logout. Closes the console if you're not in an ssh session.|
||Display all the past commands|
||Display the past 10 commands|
|Ctrl+r||Search through your history. Start typing and it will auto-complete. Hit Ctrl+r again and it will cycle though the other auto-completion options. Hit Enter and the command will execute. Hit ←,→ to edit commands.|
. (dot) is the current directory
.. (dotdot) is the upper/partent directory
/ (slash) is the root directory
~ (tilde) is your home directory
- (minus) switches to the previous directory
ls -l -a (same as above)
ls -halt (more arguments)
ls -d */ (list all directories)
ls test (contents of subfolder)
ls *.sas (show only .sas files)
|List contents of a folder
-h human readable
-l more information
-t order by time
|pwd||Print working directory
shows the current path
|clear||Clear the console
gives you a fresh view
||mkdir test||Make directory
creates a new folder with the given name
|chmod||chmod 777 test||Change permissions
777 gives the folder all possible rights
||mv text.txt test
mv test.txt bla.txt
|Move a file
Can also be used for renaming (second example)
||cp text.txt test
cp -p text.txt test
|Copy a file
-p preserves mode, ownership, and timestamps
Can also rename.
rm -rf test
rm *.tmp (removes all files with file ending *.tmp)
warning: cannot be undone!
-f force, no confirmation
dialog, no warnings
-r recursive, for folders
||sudo ls||super user do
Run a command with elevated privleges. Will ask you for a password. Only possible, if you were granted administrative rights on the system.
||less text.txt||display contents
of a file, read-only
f,b forward, backward one page
e,y forward, backward single line
n,p next, previous
-i activate case insentitive search
||history | less
ls | less
the output of a command to less.
Especially useful for history command (displays the latest commands) or folders with many files in them (last example)
||nano text.txt||file editor
Ctrl+x to close
Alt+/ to go to the end of a file
files from/to a server
-r recursive (include subfolders)
The example copies all files from the given directory then end in .txt to the local directory (dot)
||rsync -aP file.txt servername:/home/user/data||rsync
copy files from/to a server
||ls -a > result.txt
ls -a >> result.txt
the output of a command into a file
> creates/overwrites a file
>> creates/appends to a file
Connect to a server
-t Close connection immediately after the command is done
|exit||Quit server connection|
du -sh .
du -sh * | sort -h
-h human readable
||df -h||disk free
Show remaining disk space
-h human readable
|ls -1 | wc -l||Count number of files in current directory.|
|htop||View currently running processes.|
|watch||watch -n60 ls||Repeat a command every n seconds.|
|touch a file.
Creates a new, empty file if the file does
not already exist.
Especially helpful to create makefiles under Windows.
Actually the command is used for changing file timestamps.
||stat text.txt||Display file status, creation date,
last modification date, etc.
||sudo chown alice folder||change file owner|
||su root||switch user|
||passwd alice||change password|
||usermod -g grpname alice||modify a user account|
||view members of group|
|view groups of user|
chmod xxx <filename> to change permissions where
xxx is the numerical code from the table below.
Explaination of the Codes: . ... ... ... (type) (user persmissions) (group permissions) (world permissions)
The first item can be
d (a directory),
- (a regular file) or
l (a symbolic link).
The following three triplets specify permissons for the
world in that order.
In each tripplet, permissions can be
x (execute) or
- (not assigned).
Setting permissions can be done via numbers:
||000||Locking even yourself out. Use
||400||An auto-generated password file (e.g.
||444||A textfile, that others should see as well, but nobody should modify it.|
||555||A folder, that others should be able to
||755||Files and folders you want other people to see.|
||777||Files and folders you want other people to see and modify. The most open permission.|
Permissions on directory have the following meaning:
The read bit allows to list the files within the directory.
The write bit allows to create, rename, or delete files within the directory, and modify the directory's attributes.
The execute bit allows to enter the directory, and access files and directories inside.
To view permissions as numerical code:
stat -c %a <filename>.
For files, "x" means "executable" of course. For directories, it means "searchable." Without "x" permission on a directory, you can't set it to be your current directory, or get any of the file information like size, permissions, or inode number, so that you effectively can't access any of the files. If a directory has no "r" permission, you can't get a listing, but if you know a file is there, you can still access the file.
Now "s", for files, means "setuid exec." If a file has s permission, then it's executable, and furthermore, the user id and/or group id of the process is set to the user or group id of the owner of the file, depending on whether it's the user or group "s" that's set. This is a way to give limited root powers to a user -- a program that runs as root when an ordinary user executes it. For example, the "passwd" program, which can change otherwise write-protected files on behalf of a user, works this way: it's owned by the "bin" group (generally) and has g+s so that it can write to /etc/passwd and/or /etc/opasswd which are also owned by group "bin."
For directories, "s" means "sticky". If a directory has "s", then the owner and/or group of any files put into the directory are set to the owner/group of the directory. This is often used on CVS repositories, so that the files in the repository end up all owned by the same person and/or group, even though they're put in by different people. I use g+s on all the CVS repositories I set up.
|screen||Create a new session.|
|screen -S ||Create a new screen session |
|screen -ls||List all sessions.|
|screen -r||Reattach to session.|
|screen -r ||Reattach to session with |
|screen -rx ||Attach to session that is already attached.|
|Ctrl+A ^C||Create new session.|
|Ctrl+A digit||Show session 0..9|
|Ctrl+A |||Split the screen VERTICAL.|
|Ctrl+A S||Split the screen HORIZONTAL.|
|Ctrl+A Tab||Swap to next split screen.|
|Ctrl+A X||Close split screen.|
|Ctrl+A D||Detach from current session.|
|Ctrl+A "||List sessions.|
|Ctrl+A ^A||Display next session.|
|Ctrl+A Esc||Enter scroll mode. Use ↑ and ↓ or Pg Up and Pg Dn to scroll. Hit Esc to exit scroll mode.|
# Creating ssh-keygen -t rsa -b 4096 -N "" -C "" -f keyname # Setting access rights chmod 700 ~/.ssh && chmod 600 ~/.ssh/* # ~/.ssh/config Host github HostName github.com User git IdentityFile ~/.ssh/id_keyname
# Checking the ssh procesd ssh -T firstname.lastname@example.org eval $(ssh-agent -s) ssh-add ~/.ssh/keyname ssh -T email@example.com
# Detailed ls output alias ls='ls --color=auto --group-directories-first --time-style=iso --quoting-style=literal' alias ll='ls -Fails' # Count files in directory alias fcount='ls -1 | wc -l' # Disable "Save workspace" promt when closing R alias R='R --no-save' # Make FFPlay a bit more sane alias ffplay='ffplay -hide_banner -fast -autoexit -infbuf'