This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
cori_s_guide_to_linux [2015/02/13 20:06] 71.166.62.141 [Navigating around the system] |
cori_s_guide_to_linux [2017/03/12 20:44] (current) |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ====Connecting to the server==== | ====Connecting to the server==== | ||
| - | The server is running at twelvetacos.com and ssh is open on port 2242. Open PuTTY and enter the server Host Name and Port. If you want to save the connection info, enter a name for the connection in "Saved Sessions" and click save. To load a saved session, double-click on the saved session. | + | The server is running at twelvetacos.com and ssh is open on port 2222. Either pull up a terminal and connect to ssh using ''ssh -p 2222 twelvetacos.com'' or browse to https://shell.twelvetacos.com and log in there. The terminal will probably have a faster and more responsive experience. |
| - | + | ||
| - | + | ||
| - | {{:putty.png?400 |}} | + | |
| ====Initial Configuration==== | ====Initial Configuration==== | ||
| Line 18: | Line 15: | ||
| /tmp/ - Contains temporary files. | /tmp/ - Contains temporary files. | ||
| </code> | </code> | ||
| - | Your home directory will be located at /home/corina/. Your current directory will be displayed in your prompt to the right of the colon ''corina@jolokia:~$''. The tilde is a shortcut for your home directory. Some basic commands for navigating the system are below. | + | |
| + | Your home directory will be located at /home/corina/. Your current directory will be displayed in your prompt to the right of the colon ''corina@taco:~$''. The tilde is a shortcut for your home directory. Some basic commands for navigating the system are below. | ||
| <code> | <code> | ||
| pwd - Print the working directory (show where you currently are in the file system. | pwd - Print the working directory (show where you currently are in the file system. | ||
| - | corina@jolokia:~$ pwd | + | corina@taco:~$ pwd |
| /home/corina | /home/corina | ||
| ls - List the contents of the current directory. You can also provide a location as an argument to view | ls - List the contents of the current directory. You can also provide a location as an argument to view | ||
| the contents of another directory. (ls /var/www/) | the contents of another directory. (ls /var/www/) | ||
| - | corina@jolokia:~$ ls /var/www | + | corina@taco:~$ ls /var/www |
| - | corinaheich facebook reddit twelvetacos writingroots | + | corinaheich decrepitgoats twelvetacos writingroots |
| ls -l - Providing the -l option will give a long listing to include file permissions along with the owner | ls -l - Providing the -l option will give a long listing to include file permissions along with the owner | ||
| and group owner of each file. | and group owner of each file. | ||
| - | corina@jolokia:~$ ls -l /var/www | + | corina@taco:~$ ls -l /var/www |
| - | total 20 | + | total 16 |
| - | drwxr-xr-x 4 www-data www-data 4096 Feb 10 23:19 corinaheich | + | drwxr-s--- 3 root www-data 4096 Mar 11 23:43 corinaheich |
| - | drwxr-xr-x 4 www-data www-data 4096 Dec 29 23:00 facebook | + | drwxr-s--- 4 root www-data 4096 Mar 11 13:31 decrepitgoats |
| - | drwxr-xr-x 4 www-data www-data 4096 Dec 29 23:00 reddit | + | drwxr-s--- 8 root www-data 4096 Mar 11 13:31 twelvetacos |
| - | drwxr-xr-x 5 www-data www-data 4096 Jan 1 17:40 twelvetacos | + | drwxr-s--- 3 root www-data 4096 Mar 11 13:32 writingroots |
| - | drwxr-xr-x 4 www-data www-data 4096 Feb 10 22:09 writingroots | + | |
| + | cd - Change the current directory | ||
| + | corina@taco:~$ cd /var/www/corinaheich | ||
| + | |||
| + | cat - Print the contents of a file to the screen. | ||
| + | corina@taco:~$ cat /var/www/corinaheich/www/index.php | ||
| + | <?php | ||
| + | /** | ||
| + | * Front to the WordPress application. This file doesn't do anything, but loads | ||
| + | * wp-blog-header.php which does and tells WordPress to load the theme. | ||
| + | ... | ||
| + | ... | ||
| + | ... | ||
| + | |||
| + | less - Print the contents of a file to the screen, but allow scrolling through the file if it is too long. | ||
| + | The down arrow key will scroll down and the pg dn key and space bar will allow faster scrolling. | ||
| + | corina@taco:~$ more /var/www/corinaheich/www/index.php | ||
| + | <?php | ||
| + | /** | ||
| + | * Front to the WordPress application. This file doesn't do anything, but loads | ||
| + | * wp-blog-header.php which does and tells WordPress to load the theme. | ||
| + | ... | ||
| + | ... | ||
| + | ... | ||
| + | |||
| + | grep - Search files for a pattern. If you are looking for a certain pattern in a file, you can use this | ||
| + | tool. The syntax is ''grep <pattern> <file>''. You can use * as a wildcard when specifying files | ||
| + | to search for. If you want to search all files in a directory, the use ''grep <pattern> *''. If | ||
| + | you want to search subdirectories as well, specify the -r (recursive) option. | ||
| + | corina@taco:~$ grep -r "#ff" /var/www/corinaheich/www/wp-content/themes/sela-wpcom/ | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: background-color: #fff9c0; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: color: #fff; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: color: #fff; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: color: #fff; | ||
| + | ... | ||
| + | ... | ||
| + | ... | ||
| + | |||
| + | | - You can chain commands together with the | command. I mostly use this with grep when I am expecting a | ||
| + | lot of output. Instead of filling up the terminal with crap, I can pipe the output of grep into the | ||
| + | more command, which will allow me to scroll through it bit by bit. | ||
| + | corina@taco:~$ grep -r "#ff" /var/www/corinaheich/www/wp-content/themes/sela-wpcom/ | less | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: background-color: #fff9c0; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: color: #fff; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: color: #fff; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: color: #fff; | ||
| + | ... | ||
| + | ... | ||
| + | ... | ||
| + | You can also chain together multiple grep statements. This will allow you to search for one term, | ||
| + | then search those results for a second term, and so on. This is useful when I have a couple things | ||
| + | I want to search for but I'm not sure what they will be formatted like. | ||
| + | corina@taco:~$ grep -r "#ff" /var/www/corinaheich/www/wp-content/themes/sela-wpcom/ | grep "background-color" | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: background-color: #fff9c0; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: background-color: #fff; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: background-color: #fff; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: background-color: #fff; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/style.css: background-color: #fff; | ||
| + | /var/www/corinaheich/www/wp-content/themes/sela-wpcom/editor-style.css: background-color: #fff9c0; | ||
| </code> | </code> | ||
| Line 43: | Line 100: | ||
| Vim is a basic text-editing tool you can use to view and edit files. To open a file in vim, the command is simply ''vim <filename>''. Once a file is open, you will be in command mode. The mode is shown at the bottom left of the screen when not in command mode. From command mode, type ''i <enter>'' to enter insert mode. In insert mode, you will be able to modify the file as normal using the keyboard. To leave any mode and go back to insert mode, use the escape key. | Vim is a basic text-editing tool you can use to view and edit files. To open a file in vim, the command is simply ''vim <filename>''. Once a file is open, you will be in command mode. The mode is shown at the bottom left of the screen when not in command mode. From command mode, type ''i <enter>'' to enter insert mode. In insert mode, you will be able to modify the file as normal using the keyboard. To leave any mode and go back to insert mode, use the escape key. | ||
| - | To save a file, you must first be in command mode. Once in command mode, Enter '':w <enter>'' to write changes to the file. To quit the vim editor, you must enter '':q <enter>''. If you want to save and quit, you can combine these commands and use '':wq <enter>''. This is what I use most of the time. If you want to quit without saving changes, you have to use '':q! <enter>'' to tell vim you want to quit without writing changes to the file. If you receive an error about the file being only 'readonly', you must quit without writing changes as you do not have the right permissions to edit the file. | + | To save a file, you must first be in command mode. Once in command mode, Enter '':w <enter>'' to write changes to the file. To quit the vim editor, you must enter '':q <enter>''. If you want to save and quit, you can combine these commands and use '':wq <enter>''. This is what I use most of the time. If you want to quit without saving changes, you have to use '':q! <enter>'' to tell vim you want to quit without writing changes to the file. If you receive an error about the file being only 'readonly', you must quit without writing changes as you do not have the right permissions to edit the file. To search the file, you can use the '/' character from command mode. It will move the cursor to the first instance of the word that follows the slash you typed. Hit 'n' to go to the next instance. |
| + | |||
| + | <code> | ||
| + | vim <filename> - Open a file | ||
| + | corina@taco:~$ vim /var/www/corinaheich/www/index.php | ||
| + | |||
| + | :w - Write changes to a file | ||
| + | :q - Exit vim when no changes are left to be written | ||
| + | :wq - Write changes to a file and quit | ||
| + | :q! - Exit vim without writing changes to file | ||
| + | /word_i_want_to_search_for ('n' to view the next occurrence) | ||
| + | </code> | ||
| + | |||
| + | ====Web Content and Wordpress==== | ||
| + | All web server content is located in '/var/www/'. /var/www/ contains subdirectories for each of the domains hosted on the server. Within each domain subdirectory is a root directory. This is where the content is located. All of your wordpress content is located in ''/var/www/corinaheich/www/''. Most of the stuff you will be interested in is located in the ''wp-content'' subdirectory. Wordpress stores theme and plugin information. You can use ls and cd to explore these subdirectories. | ||
| + | |||
| + | To fix things in wordpress, a lot of times it is easiest to use firebug in firefox (f12 when viewing a page) and find the element that is giving you trouble. If you want to find and modify the class it belongs to, you can grep for the class name on the server in the plugin's or theme's directory. Once found you can use vim to modify the part you want. | ||
| + | ====Final Notes==== | ||
| + | To view more information on how to use a command, you can use the ''man'' command. Simply enter ''man <command>'' to view the manual for and usage of that command. | ||