Commands - Basic

From 2047Servers Support
Jump to: navigation, search
 
Line 1: Line 1:
 
[[Category:Linux]]
 
[[Category:Linux]]
  
<center>
 
[[File:linux.png|200px]]
 
</center>
 
  
=== Creating Users / Groups ===
+
[[File:linux.png|thumb|350px]]
  
=== Installing / Removing & Upgrading Software ===
+
 +
Here is our mini selection of some basic & commonly used commands, see other pages for more in depth command lists
  
=== Checking Server Status & Monitoring ===
+
== Creating Users / Groups ==
  
=== File / Folder Management ===
+
See our full in depth guide on [[Linux_User_%26_File_Management|Linux User & File Management]]
 +
 
 +
==== Creating Users ====
 +
 
 +
Having multiple user accounts can be a great idea if you are having multiple people manage the server or parts of it.
 +
 
 +
<pre>useradd username</pre>
 +
 
 +
Once you have created a user you will want to set the password for this user, Use command
 +
 
 +
<pre>passwd username</pre>
 +
 
 +
This will then prompt you for a password for this user.
 +
 
 +
==== Creating Groups ====
 +
 
 +
Groups are very useful for managing a group of users that you want to have the same permissions e.g. You might want a group that will be able to edit files for all of your Counter Strike Servers, or just some. By adding users into groups you only have to set the access rights for a group not for every single user
 +
 
 +
<pre>groupadd groupname</pre>
 +
 
 +
If you want to add an existing user to a group you can user command (-a for Add, -G for Group)
 +
 
 +
<pre>usermod -a -G groupname username</pre>
 +
 
 +
== Installing / Removing & Updating Software ==
 +
 
 +
As you use your server / install programs on it, you may find you need some software to run it. For example Minecraft Server requires you have Java installed as its main component.
 +
 
 +
If some software isn't installed & you are trying to run the software, The OS will kindly let you know it isn't installed & tell you the command to install it (For Common/Well known Software only)
 +
 
 +
==== Installing Software ====
 +
<span style="color:#ff0000"> Depending on your system there can be some slightly different commands for CentOS based servers you mainly use the "yum" command & for Debian/Ubuntu based servers you use the "apt-get" command (Make sure you adjust the commands below to match your OS)</span>
 +
 
 +
Installing software on Linux based systems is very easy via commandline all you have to do is type the name of the software you want installed & if the main distribution servers have it, your server will be able to download & install this software for you.
 +
 
 +
Replace software name with the software you want to install
 +
 
 +
<pre>apt-get install software</pre>
 +
 
 +
==== Removing Software ====
 +
 
 +
For any reason that you want to uninstall software you can use a similar command to do that for you. (Note with some software it may leave configuration files behind, what you may have to delete before re-installation)
 +
 
 +
<pre>apt-get remove software</pre>
 +
 
 +
==== Updating Software ====
 +
 
 +
<pre>apt-get update software</pre>
 +
 
 +
You can also use this command below to update all software packages (this will just download the updates)
 +
 
 +
<pre>apt-get update</pre>
 +
 
 +
Use the command below to install the updates you just downloaded (if you done the step before)
 +
 
 +
<pre>apt-get upgrade</pre>
 +
 
 +
== Server Monitoring ==
 +
 
 +
It is normally a good idea to add some server monitoring tools to your server, the most popular ones for game servers is creating a game server monitor button see a place like [http://www.gametracker.com Gametracker.com] These create banners like the example below, what can be useful to check on just to see how many players are on the server & if it is online.
 +
 
 +
[[File:gametracker.png|400px]]
 +
 
 +
Our favourite server monitoring tool is "htop" this is a bit like Windows Task Manager but for Linux, we install this software as standard, to run htop use command
 +
 
 +
<pre>htop</pre>
 +
 
 +
Below is a screenshot of what htop looks like, You can edit what is displayed on htop by press "f2" to go into the setup menu
 +
 
 +
[[File:htop.png|550px]]
 +
 
 +
Another great tool called "iftop" can be used to monitor your servers traffic, this tool lets you know who is connecting to your server & the network stats of the connection
 +
 
 +
<pre>iftop</pre>
 +
 
 +
Below is a screenshot of what iftop looks like
 +
 
 +
[[File:iftop.png|550px]]
 +
 
 +
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 ==
 +
 
 +
=== 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>
 +
 
 +
To navigate to the parent folder (folder above) use command "cd .."
 +
 
 +
<pre>cd ..</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 on [[Linux_User_%26_File_Management|Linux User & File Management]]

Latest revision as of 14:58, 3 February 2013

Personal tools
Namespaces

Variants
Actions
Navigation
Categories