Skip to main content
Topic: Typical Linux commands thread (Read 2278 times) previous topic - next topic

Typical Linux commands thread

Hey guys,

I've been using linux for a while and I'm looking back at my written notes on linux shell use.  I'm trying to type them in my computer to be a bit more organized (and in case I lose my notes, I have something backed up).  I thought as I slowly get them into my computer that I would share with you guys what I've learned.  I'll fix it up as I have more time and let me know if something doesn't look right... anyways Enjoy.

General command syntax
   ls – shows list of a directory
cd – change directory
   cd ~
   ~ shows user home folder
   changes your directory to the home folder
cd -
 the - at the end of cd brings you to the previous directory
   sort – sorts based on alphabet?
   sort – sorts out redundancies in a file
   sort -u dupes.txt
      -u unique (no repeating lines)
   grep – basically searched files with specific keywords in them
   grep – search files for text that matches a given pattern.
      grep “the” poems.txt
      Basically find where the word “the” shows up in poems.txt
   man – view the reference manual or man page for a specific command (-h works too)
ls -l does more info in the list
mkdir – makesdirecotry
rm – removes
cp – copy
   EX:  First file is the copied file, second file is the pasted
   cp hello.txt hello_there.txt
. shows us our current directory
su root – maintains super user rights
cat – concatenate and print files
vi – open vin text editor In shell
find - command looks for files
      EX: find . -name “do*”
      . – find file in current directory
      -name – find file by name

      “do*” – find file with the name do followed by any character afterwards

Quick Buttons
CTRL+SHIFT+(+) makes the font bigger
CTRL+A – moves to the beginning of the line
CTRL+E – moves to the end of the line
CTRL+left arrow – moves backwards a word
CTRL+right arrow – moves forward a word
CTRL+U – deletes from cursor to the beginning of the line
CTRL+k – deletes from cursor to the end of line
CTRL+SHIFT+C – copy to clipboard
CTRL+SHIFT+V – paste from clipboard

File permissions
   rwxrwxrwx the_file
   you can look at it as rwx – user: rwx - group : rwx - others
      First group of rwx is the user
      Second group is the group
      Third group is the others
      R – read
      W – write
      X - execute
Chmod – changes the perissions on a file by modifying the file made bits
   There are different things for representations
      Octal (755, 644)
      Symbolic (=, -, +)
   To change permissions for all users in a directory
      Chmod a-x test.sh
Table   Read (4 points)   Write (2 points)   Execute (1 point)   Result
User   R   W   X   7
Group   R   -   X   5
Others   R   -   -   4

Symbolic   Read   Write   Execute   Result
User (u)   +   +   +   U=rwx
Group (g)   =   -   -   G = r
Others (o)   -   -   -   O = nothing

Chown – change ownership

Misc
wildcards - are characters that stand for patters
      (*) any number of characters
      ? one of any character
sudo -k – gets out of sudo
./ - executes a program
   ./calculator
| - (pipe character) takes the output of one command and sends it to another.  Type it in between commands
echo – same thing as print or echo in php
cat – concatenate and print files
head and tails – command lets us see the beginning and the end of the text file.
   Head poems.txt
-n – in head shows how many lines after you gonna show
awk and sed – tools that extract or modify text from  a file or stream
   awk ‘{print $2}’ simple_data.txt
   sed s/orange/red/ simple_data.txt
   s substitutes every occurrence of orange with red
tar files – type archive files
   Basically they are files within a big file
   Tar -cvf myfile.tar Exercisefiles/
      -c create an archive
      -v list out each file that gets added to the archive
      -f output to a file
To find your distribution type:
   Cat /etc/*-release  or  uname -a
free -h shows your ram
cat /proc/cpuinfo
   Shows random things within the computer
(for fedora) sudo dnf install nano
   dnf shows what you are about to install on the machine
(for ubuntu (Debian))
   sudo apt-get update
      Advanced package tool

Cloning things from github:
   git clone git://github.com/<github directory>


                  

Re: Typical Linux commands thread

Reply #1
You should definitely know about: https://github.com/chubin/cheat.sh
                  

Re: Typical Linux commands thread

Reply #2
linux-commands-cheat-sheet-new.pdf > https://docdro.id/oQU2bTG
                  

Re: Typical Linux commands thread

Reply #3









                  

Re: Typical Linux commands thread

Reply #4
Ok, this is amazing.  Thanks for this.