1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
Your setup may be different to mine, but here is a cheetsheet with some of the commands I use the most while messing with/setting up my server.
All these commands assume you are a user with username "alex" and your home directory is in the default location.
cd - change directory - moves through the file tree
Example: cd /home/alex/
Moves into your home directory, you usually have read, write, and execute access to everything in this directory.
Example: cd ~
Same as above, ~ is a substitute for your home directory, so if you were a user named "bob", 'cd ~' would move to /home/bob/
Example: cd ..
Moves to the parent directory, so if you were in /home/alex/documents, and you executed 'cd ..' you would now be in alex/home/
ls - list directory - lists the contents of the current directory you are in
Example: ls
If you are currently in /home/alex/, lists all files and folders contained in /home/alex/
Example: ls /home/alex/pictures/
Lists all the files and folders in /home/alex/pictures/
Example: ls -l
Lists all files and folders, with their permissions, owner, and group displayed
Executing bash scripts: Simply type the name of the bash script, for example if you are in /home/alex/, and the 'ls' command shows a file called do_something.sh, simply type './do_something.sh' you can also use absolute file path(/home/alex/do_something.sh) or relative filepath (~/do_something.sh, assuming you are the user alex)
Viewing files: Remember that you are on a command line, which means you can't view things like pictures without downloading them to your local computer and using a image viewing program to view them. That said, text files can be viewed
cat - concatenate - appends the file to the command line
Example: cat foo.txt
If the file foo.txt is in the current directory, and contains the text 'Hello, world!', 'Hello, world!' will be shown on the command line
nano - A very small text editor - the rough equivalent of Notepad.exe
Example: nano foo.txt
If we assume the same file from the previous example, you can now move the cursor around the file with the arrow keys. The shortcuts are displayed at the bottom, in linux '^' means control, so to save a file, you would press crtl+o, and to exit you would press ctrl+x
The default shell on my server is called 'bash' and has tab-completion for most things, you you can't quite remember how to spell a folder name, you can press tab twice, and it'll list the the child folders of whatever path you have typed so far.
|