Commands - Basic
From 2047Servers Support
| Line 87: | Line 87: | ||
[[File:iftop.png|350px]] | [[File:iftop.png|350px]] | ||
| + | |||
| + | Simple Commands like "free" can show memory usage | ||
| + | |||
| + | <pre>free</pre> | ||
| + | |||
| + | "du" can show the disk usage | ||
| + | |||
| + | <pre>du</pre> | ||
| + | |||
| + | "df" can show us the disk used/free space on each hard disk | ||
| + | |||
| + | <pre>df</pre> | ||
== File / Folder Management == | == File / Folder Management == | ||
| + | === Navigating around the file system === | ||
| + | |||
| + | To change which folder you are in / navigate to another folder you use the command "cd" (change directory) & then the folder path (you can press tab for auto complete, or tab tab for a list of options that match you search e.g. | ||
| + | |||
| + | <pre>cd /home</pre> | ||
| + | |||
| + | === Showing the contents of a folder === | ||
| + | |||
| + | To show the contents of a folder you can use the command "ls" (List) This will list all the files / folders in your current directory | ||
| + | |||
| + | <pre>ls</pre> | ||
| + | |||
| + | You can also use the better command "ls -l" this will list more information about the files / folders, including permissions, owner, size, last modified | ||
| + | |||
| + | <pre>ls -l</pre> | ||
| + | |||
| + | |||
| + | === Editing files === | ||
| + | |||
| + | For most of the time you should be able to do everything you need using the command line tools & file editors such as "nano" a brilliant command line text editor for Linux | ||
| + | |||
| + | This command will either open the file "file.txt" if it exists, or it will create a file "file.txt" using this text editor | ||
| + | |||
| + | <pre>nano file.txt</pre> | ||
| + | |||
| + | For other files with different file types that are not supported with text editors, it maybe best to download the file & then edit using a local computer | ||
| + | |||
| + | === Copying Files / Folders === | ||
| + | |||
| + | To copy a file / folder you use the command "cp" (Copy) & then the file you want to copy & then the destination e.g. for a single text file this command will copy "file1" to "file2" | ||
| + | |||
| + | <pre>cp file1.txt file2.txt</pre> | ||
| + | |||
| + | If you want to copy a folder the command is slightly different you just add the "-r" option to the command to specify you want to recursively copy a folder & its files within (This command will copy "folder1" into "folder2" | ||
| + | |||
| + | <pre>cp -r folder1/ folder2/</pre> | ||
| + | |||
| + | It is best to use the copy command if you want to move files / folders via command line. | ||
| + | |||
| + | === Renaming Files / Folders === | ||
| + | |||
| + | There are multiple ways of doing this, you could edit a file in a text editor like "nano" from the above example & then save it as a different name or you can use the "mv" command | ||
| + | |||
| + | In this example i will rename file1111.txt to file.txt | ||
| + | |||
| + | <pre>mv file1111.txt file.txt</pre> | ||
| + | |||
| + | You use the same command to rename a folder | ||
| + | |||
| + | <pre>mv folder1111 foldera</pre> | ||
| + | |||
| + | === Making Folders === | ||
| + | |||
| + | A very simple command for this one "mkdir" (Make Directory) in this example I will create a folder named testing | ||
| + | |||
| + | <pre>mkdir testing</pre> | ||
| + | |||
| + | You can also specify a path in which you want to create the folder in, very useful if you want to copy files from one place to another & placing them in a folder | ||
| + | |||
| + | <pre>mkdir /home/testing</pre> | ||
| + | |||
| + | |||
| + | === Deleting Folders === | ||
| + | |||
| + | If you want to delete a folder you use the command "rmdir" to delete an empty folder, if it has files inside it you use the command "rm -r foldername" example. | ||
| + | <pre>rm -r testing</pre> | ||
- See our Full in depth guide [[Linux_File_Management|Linux File Management]] | - See our Full in depth guide [[Linux_File_Management|Linux File Management]] | ||