• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Linux [Linux] Basic commandline usage

scriptha

On a distinguished road
Joined
Jul 21, 2007
Messages
125
Reaction score
0
Location
/etc/pr0n
Hi

Since linux is leet, and commandline is that too, I made a little overview of useful commands.

Navigating
Opening the commandline shouldn't be a problem. Open it.
You are probably in your /home/user/ directory. (If you don't know in which directory you are, type pwd) Now type 'ls'.
You'll get a list of files, where directories are blue, executables are green etc.
You now know your first command ^^
You want to list other dirs too ofcourse. If you want to navigate to another directory, you use the cd command, which stands for change-dir. You just listed the files in your directory, so you know which dirs you have. Pick one, Desktop for example, and type cd Desktop. You're in /home/user/Desktop now :thumbup:. If you want to go back, one directory up, you use cd ..
.. will get you to /home/user.
Last, you can navigate directly to a directory by typing it. If you are in /usr/lib for example, you can go to /home/user directly by typing cd /home/user
You're now able to navigate through your filesystem with cmd ^^


File moving, copying, removing and creation.
You have a filesystem to create files on, so lets do so! To create a file called foo.txt, you type in touch foo.txt. If you want to create that file on another location, you can type in the full path, like touch /home/user/foo.txt
Or, if you want to create the file two dirs up from your current dir, you type
touch ../../foo.txt.

If you want a copy of foo.txt, you type in cp foo.txt bar.txt. A second file called bar.txt will be created, an exact copy from foo.txt. You can copy this to another location with cp foo.txt ../bar.txt, you can use cp /usr/lib/foo.txt /home/user/Desktop/. Note that I have not specified a filename, so the new file will be named like the original.

Removing works with the command rm. Type in rm foo.txt and foo.txt will be removed. Important note: There is no recycle bin in linux, so if you remove a file it will be permanently lost!

And last, moving. Moving works with mv. You can move like this:
mv /usr/lib/bar.txt /home/user/, and bar.txt will be moved to /home/user/.
You can also use mv foo.txt .., and you can give the file a new name:
mv foo.txt bar.txt. That's renaming too, you don't have a separated renaming command...

Creating and removing direcories
Note: You move a dir the same way a you move files.
You create a directory with mkdir dirname. You can specify a path, mkdir /home/user/dir for example.
You remove the dir and everything in it with rm -r dir
You create and remove a dir called foo like this:
mkdir foo
rm -r foo


:O That's it for now, I'll write about reading files and putting data in them later. Please post all typos you find ^^
 
If you want a copy of foo.txt, you type in cp foo.txt bar.txt. A second file called bar.txt will be created, an exact copy from foo.txt. You can copy this to another location with cp foo.txt ../bar.txt, you can use cp /usr/lib/foo.txt /home/user/Desktop/. Note that I have not specified a filename, so the new file will be named like the original.
 
Oh... speaking of Shells...

"Linux: the operating system with a CLUE... Command Line User Environment". (seen in a posting in comp.software.testing)

... of course, this probably only happens for tcsh which uses wait4(), which is why I never saw it. Serves people who use that abomination right 8^) (Linus, about a patch that fixes getrusage for 1.3.26)
 
Back
Top