Jump to content

some basic CLI commands


Recommended Posts

I would like to learn some basic CLI commands that will allow me to do:

 

- turn on/off the X server

- start/stop/restart services

 

I'm using Mandriva & FC4 so that commands should work in both systems.

 

What are these commands?

Thanks.

Link to comment
Share on other sites

It should work in fedora. How are you doing the su? If you do:

 

su

 

then you need to type:

 

/sbin/service name start/stop/restart

 

If you type:

 

su -

 

then you can use:

 

service name start/stop/restart

 

and to get a list of services:

 

chkconfig --list

 

of course, without doing "su -" you need:

 

/sbin/chkconfig --list

 

I found this when using fedora and not using the su command correctly.

Link to comment
Share on other sites

in all linux (and bsd, even unix IIRC) distributions you should be able to do one of the following two:

/etc/rc.d/servicename start|stop|restart

or:

/etc/init.d/servicename start|stop|restart

for example:

/etc/init.d/network stop

where init.d could also be rc.d. as far as X11 goes, if it's starting at boot and your using a display manager you should be able to do:

/etc/init.d/gdm stop

where gdm could also be either kdm, xdm or just plain dm. i believe both fedora and mandriva use the init.d framework.

Link to comment
Share on other sites

[ilia@linux-fc4 ~]$ su
Password:
[root@linux-fc4 ilia]# service smb restart
bash: service: command not found
[root@linux-fc4 ilia]# /sbin/service smb restart
Shutting down SMB services:								[  OK  ]
Shutting down NMB services:								[  OK  ]
Starting SMB services:									 [  OK  ]
Starting NMB services:									 [  OK  ]
[root@linux-fc4 ilia]#

 

Problem is solved. Thank you guys. What about X or Gnome session?

Link to comment
Share on other sites

like i said (though I wouldn't expect you to read my post :P )...try using dm/gdm/xdm/kdm as the service...using what worked for you, you should try this:

/sbin/service dm stop

assuming you're using a display manager - as the DM actually initiates the X session. If you aren't using a display manager then you'll probably have to use kill as X doesn't normally have a service of it's own. so I would check to see if the above works, otherwise is a matter of finding the PID of the X process and killing that.

Link to comment
Share on other sites

and if you don't want to type the /sbin/ before the service command, just do this to get root privileges instead:

 

su -

 

the minus is required to ensure the path searches are loaded.

Link to comment
Share on other sites

More specifically:

 

< root /home/omar > su --help
Usage: su [OPTION]... [-] [USER [ARG]...]
Change the effective user id and group id to that of USER.

 -, -l, --login			   make the shell a login shell

 

You are making it a login shell, so that it sources your /root/.bashrc, /root/.bash_profile, etc.

Link to comment
Share on other sites

it's ok, i'm used to being ignored :D ;)

What... who are you?

 

su let you log as root but the path is still under your regular user, while su - let you log as root with all the path of user ROOT...

 

checking kernel ver. at cli..

 

uname -a

Or more specifically uname -r

 

-a is a good fallback but when using scripts unname -r gives the exact kernel so you can quote it as a llteral string and use it for urpmi etc.

 

 

apt-get install kernel-headers-`uname -r`

instead of the clunky

apt-get install kernel-headers-`uname -a | cut -f 3 -d' '`

 

change apt-get to urpmi for mandriva.....

 

There is a great O'reilly unix/linux tool kit site with loads of stuff like this ... well worth a google.

The thing is the more you use and the more generic the more you can combine ..

 

This is why tymes method is IMHO much better because its universal (only changing the rc.d or init.d dirs according to SYS V or BSD) ....

 

edits missed 1st example

Edited by Gowator
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...